 |

|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|

|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|

|
I use System.threading.timer() to read RS232 data periodically,
But I found it seems the threading.timer() produces many threads,like each cycle it use a new thread to read.
Is the threading.timer use many threads of threadpool?
|
|
|
|

|
I got error message while installing an VB.NET applicaiton -
"Cannot Start Application
An error has occurred writing to the hard disk. Check if there is enough available space on the disk. Contact the applicaitonh vendor..."
In the Detail, it has -
"ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of C:\amldoc1\VB 2003\Project\FTT\publish\NetCommFieldTestTool.application resulted in exception. Following failure messages were detected:
+ Downloading file:///C:/amldoc1/VB 2003/Project/FTT/publish/Application Files/NetCommFieldTestTool_1_0_0_0/Converter.netmodule.deploy did not succeed.
+ The file 'C:\Users\aoum\AppData\Local\Temp\Deployment\K4ZJZGMC.N2C\5045Z1V0.DDV\Converter.netmodule' already exists."
I have tried the solution posted on your site --> Publish - Application Files and select "Include" for all dll files.... still the same error.
Any idea or suggestion?
Thanks for your help!!
|
|
|
|

|
How to view the list of PC names on the LAN using vb6
|
|
|
|

|
Is the VB.NET winform application multithread or single thread?
if I want to use threading.timer in a VB.NET application, do I need pay attention to the MTA, or STA?
|
|
|
|

|
I wrote a small program, just want to test DateTime.Now and System.Timers.Timer.
I set Timer interval = 50/40, i.e 50ms/40ms
And in the timer elapsed event, call a StreamWriter.write() function,
tstText = "111" & Space(11) & Format(now, "hh:mm:ss.fff ")
mFileStreamWriter.Write(tstText)
But I found in the text file which stors the data, the timer resolution is 62-65 ms.
01:38:13.423
01:38:13.485
01:38:13.548
01:38:13.610
01:38:13.673
01:38:13.735
01:38:13.798
01:38:13.860
01:38:13.923
How can I make the resolution to 50ms, 40ms? or it is impossible to do it in Windows OS or any OS?
|
|
|
|

|
After some operations, I want to set the StreamWrite object be NULL.
Now the code I wrote as follows:
mFileStreamWriter.Flush()
mFileStreamWriter.Close()
mFileStreamWriter = Nothing
But MSDN said is/isNot only used to compare the reference, not value.
So = Nothing means let an object refer to Nothing, right?
|
|
|
|

|
Hi all...
I have a questions about opentype font ...
whether we can show OpenType feature in vb.net?
and if it can where I can get a tutorial and script
Thank you for reply
best wishes,
dee
|
|
|
|

|
hi
is it possible change the level of visualization of an shape (textbox, image, label ....)?
If I've two shapes in the same position and i wanted to see the shapes behind is possible change the priority of visualization?
ps the answer is ok for VB and C#
|
|
|
|

|
Hi all.
For some reason, whenever I open a project in vb.Net 2010, and open a document, it scrolls uncontrollably to the bottom of the page. I can't get it to stop.
What's up.
|
|
|
|

|
I have a utility which loops through our LDAP fetching all of the CN values out to a .csv file, I am validating this against an Excel document which contains our phone number list. The problem is that for some people, I do not find a LDAP entry.
I have another utility which takes as input the Username of someone and dumps out all of the attributes found in our LDAP and when I use this utility to find a person which is not listed on the main dump file, I do find him.
I wrote both utilities, so the fetching logic is very similar.
The looping utility uses:
Dim de As New DirectoryEntry("LDAP://DC=us,DC=myCompany,DC=com")
ds.Filter = "(&(objectCategory=person))"
While the single user verifier uses:
Dim de As New DirectoryEntry("LDAP://DC=us,DC=myCompany,DC=com")
ds.Filter = String.Format("(SAMAccountName={0})", Me.tboxUserName.Text)
I have looked at the LDAP properties of 2 users; UserA is the guy I don't have in my .csv file and UserB who is listed in the .csv file and nothing obviously jumps out at me being different.
Where should I be looking to resolve this issue? If I can find a user directly by his username, then he should be part of the .csv export file. Right?
Thanks in advance for your guidance.
|
|
|
|

|
Howdie.
Has anyone encountered vb.Net reversing your edits to a project?
I just spent two days looking for a problem that took me so long to figure out because I had previously made some edits that I know were fixed, so I did not go back there until it was obvious the problem was there....Again! I had about 5 win32 functions that I needed to change from Private to Public, and a few ByRef that needed to be switched to ByVal. I was testing the program fine for a few days WITH THOSE FIXES ALREADY MADE, when all of a sudden I was getting odd errors that were hard to nail down":
"Cannot evaluate expression because the code of the current method is optimized."
and
"Exception of type 'System.ExecutionEngineException' was thrown."
The first error was difficult to nail down because it was silent and GetLastError() just returned 0 (function executed successfully), and the last error gives no indication of the problem source. Fortunately the last error went away with the solution to the first.
Basically what vb.Net did was change two of my Public back to Private, and switched one ByVal back to ByRef.
Very strange.
|
|
|
|

|
Hello,
using VB.Net and TAPI 3.x I created a little application to make and recieve calls. This application uses an ordinary telephone which is connected via USB to the computer.
Most functions seem to work fine, but there are some problems which I can't solve:
- If you take the telephone receiver off the phone and then make a call via my computer application Visual Basic reports an unknown error with the code 0x80040052.
- My application don't recognizes phone events and digit events!
It would be great if someone could help me. I studied nearly everything you can find about TAPI in the internet, nevertheless I don't know how to solve these problems.
Yours faithfully,
Steven
|
|
|
|

|
Hi everyone,
i am trying to write a simple code that reads a bitmap image, i.e ("c:\test.bmp"), then i would like to read every pixel and make a check if the pixel is wether a white or black pixel , to finally counting the number of black pixels in the image:
my code was like this :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tst As New Bitmap("c:\tst.bmp")
PictureBox1.Image = tst
Dim x, y, bcnt As Integer
Dim c As Color = tst.GetPixel(x, y)
bcnt = 0
For y = 0 To tst.Height - 1
For x = 0 To tst.Width - 1
If tst.GetPixel(x, y) = Color.Black Then
bcnt = bcnt + 1
End If
Next
Next
MsgBox(bcnt)
End Sub
|
|
|
|

|
Hi frnds, Is there any codings to filter the data from the Excel Sheet using Visual Basic?
I need codings pls send it as soon as possible..
|
|
|
|

|
Hi.
I'm not sure whether or not this thread should go here or over in the API section, except that it involves declarations that are definitely vb.Net.
Anyway, my questions revolve around the use of IntPtr. My first thought was that since I needed to pass pointers to win32 functions, I needed to restrict myself to 32bit values. Therefore, it seems that IntPtr is only applicable when on a 32bit system. If a pointer is declared as IntPtr on a 64bit system, vb.Net is clever enough to make IntPtr fit the 64bitwidth of the current system. That makes it unusable for win32 functions because they can only deal with 32bit values. So then I thought, well, I'll switch to using UInt32, so that the API is accessible with a 32bit pointer. But then I thought, hm, that would be fine as far as the API function is concerned, but would create a problem when an API function returns a 32bit encoded address to a memory location on a 64bit system! So that seems to suggest that when you get the pointer out of the function, that it needs to be widened to a 64bit pointer so that the data there can be properly found and retrieved. So my questions are:
1. Is this logic basically correct?
2. Is IntPtr really nothing more than UInt32 or UInt64,
depending on the bitwidth of the system?
3. Again, if all of this is correct, is casting or
marshaling required to narrow and widen the pointer
when a conversion is necessary?
modified 8-Jun-13 23:14pm.
|
|
|
|

|
Hello,
I have an app that utilises web browser object to open a (local) html file enter pass that runs javascript within the html(nothing to do with me) that opens/ decrypts another HTML page with links to the encrypted files.. ..
All works fine for 1 or 2 files but I have 200+ that I have to convert. Without fail and at unfortunately but not on a particular file the app crashes and returns StackHash Error... I have added the exe to DEP Exceptions list. Rebooted and the error still returns.
How can i find out what is causing this error?
Hope somebody can help on this.
The crash occurs at the same piece of code. which is:
Sub HTTPDownloadFile(ByVal URL As String, ByVal LocalFileName As String)
Dim http As New Inet
Dim Contents() As Byte
On Error GoTo HTTPDownloadFile_Error
WriteLog "LInk" & URL
WriteLog "Path to save" & LocalFileName
10 20 30 With http
40 .protocol = icHTTP
50 .URL = URL
60 Contents() = .OpenURL(.URL, icByteArray)
70 End With
80
90 Open LocalFileName For Binary Access Write As #1
100 Put #1, , Contents()
110 Close #1
120 Set http = Nothing
WriteLog LocalFileName & "Saved"
On Error GoTo 0
Exit Sub
More specifically between the open and close statements.
Has anybody any suggestion as to what may cause this or how to avoid? this is my first step into vb so am cluelss about various compilation options.. would/ could any of thoese options help?
FYI am running on windows 7.
Thanks in advance.
|
|
|
|

|
how to get replication status from sqlserver 2005 in vb.net ?
|
|
|
|

|
i have softwares prepared on VB.net 2005 and inside my code there is msgbox contain arabic letters
the problem come when i open my code but surprise about new letter come instead of my arabic letters
for example i see
MsgBox("åá ÊÑÈÏ ÈÇ ÇáÞíÇã ÈÚãáíÉ ÇáÊÚÏíá")
i search on google and i find that this letters is icelandic and portuguese language
how i can recover my language inside the code
|
|
|
|

|
Hi Guys,
I have a quick and hopefully not to difficult question to the commmunity. I have a program that reads an excel spreadsheet, adds the data to a datatable inside a dataset and displays it in a wpf datagrid using databinding.
Here is the code for it, it works fine just like I imagined it . I also have a funciton that returns all the sheets in a excel spreadsheet.
Private Sub Button_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim m_sConn1 As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:\Temp\Test.xlsx;" & _
"Extended Properties=""Excel 12.0 Xml;HDR=No;IMEX=1"""
Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1)
conn1.Open()
Dim da As OleDbDataAdapter
Dim ds As New System.Data.DataSet
Dim test As String
test = "[Sheet1b$]"
Dim teststring As String
teststring = "Select * FROM" & test & """"
da = New OleDbDataAdapter(teststring, conn1)
da.Fill(ds, "TestTable")
da.Dispose()
Dim bindingSource As New BindingSource(ds, "TestTable")
excelDataGrid.ItemsSource = bindingSource
conn1.Close()
End Sub
Private Sub getList_Click(sender As Object, e As RoutedEventArgs) Handles getList.Click
Dim m_sConn1 As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:\Temp\Test.xlsx;" & _
"Extended Properties=""Excel 12.0 Xml;HDR=No;IMEX=1""" Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1)
conn1.Open()
Dim test As New System.Data.DataTable
test = conn1.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
If test Is Nothing OrElse test.Rows.Count < 1 Then
Throw New Exception("Error: Could not determine the name of the first worksheet.")
End If
Dim firstSheetName As String
Dim i As Integer
For i = 0 To test.Rows.Count - 1
firstSheetName = test.Rows(i)("TABLE_NAME").ToString()
List1.Items.Add(firstSheetName)
Next
End Sub
My question now is this. I'd like to have the program iterate through the first column of the data and match the entries with known parameters. For example. the user has a cell that says EmpID, I want the program to recognize it and change it to Employee ID. Upon recognizing all of these, I want the program to display the data with the new cell values in a different datagrid.
My thought was this: Load data from excel -> fill datatable in dataset -> bind data to datagrid for visual confirmation that data was imprted correctly -> in different sub obtain the databinding for the wpf datagrid and fill a new datatable in a new dataset -> go through the recognizing function -> and spit out the data in a new datatable
I tried looking for a way to do it but am having trouble with getting the data. All I could find online was how to get data into a datagrid and not the other way around.
initially I thought it would be as simple as
Dim TestDataTabe As System.Data.DataTable
TestDataTabe = DirectCast(excelDataGrid.ItemsSource, System.Data.DataView).ToTable
but that didn't seem to work and it told me an error: Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'System.Data.DataView'.
so now I am stuck and can't find anything on Dr. Google about getting the datatable that is used to fill the datagrid. Would someone be able to help me out, it would be greatly appreciated. Is it possible to have a databinding for a datatable? As in Datatable.bindingsource = datagrid.bindingsource?
Update:
so it seems that I always sorta solve my problems when I post on a forum lol. So here is what I did and hope that you guys can give me input to see if it is a viable way to do this sort of thing.
Instead of creating a dataset I created a datatable and instead of using binding source I used datagrid.itemssource = datatable.defaultview
then i direct casted it totable here is the code
Private Sub Button_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim m_sConn1 As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:\Temp\Test.xlsx;" & _
"Extended Properties=""Excel 12.0 Xml;HDR=No;IMEX=1"""
Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1)
conn1.Open()
Dim da As OleDbDataAdapter
Dim ds As New System.Data.DataTable
Dim test As String
test = "[Sheet1b$]"
Dim teststring As String
teststring = "Select * FROM" & test & """"
da = New OleDbDataAdapter(teststring, conn1)
da.Fill(ds)
da.Dispose()
excelDataGrid.ItemsSource = ds.DefaultView
conn1.Close()
End Sub
Private Sub Button_Click_2(sender As Object, e As RoutedEventArgs)
Dim TestDataTabe As System.Data.DataTable
TestDataTabe = DirectCast(excelDataGrid.ItemsSource, System.Data.DataView).ToTable
End Sub
Now I got more questions lol How would you set the itemssource of the datagrid to a table inside a dataset? Sorry for the long post but maybe it helps someone out.
|
|
|
|

|
I want to convert VB6 project to VB.Net. I an facing some problems.
I have separated huge VB6 project into separate dlls based in functionality. All business logic is in dll and UI is in exe program.
Out of all dlls, one dll only caontains UDT(User Defined Types) and it's used by Main exe program and all other dlls. Now I want to Convert all dlls and main program in VB.Net STEP BY STEP. I have decided to convert all dlls first and then main program.
If I convert other dll to .Net I ran into Case1 error
If I convert UDT dll to .Net using Structure, I got case 2 error
I am giving my dummy code for both the cases and problem/error description below.
Case 1:
UDT dll is in VB6 -->Name: Dll_EmployeeType
Type Employee_Properties
Employee_Id as integer
Employee_Name as String
Employee_Address as string
End Type
.Net Dll -->Name: Dll_Employee_Methods --> this refers vb6 dll Dll_EmployeeType
Class Cls_Employee
Function Display_NoOf_Employees(byval arr_employee as Dll_EmployeeType. Employee_Properties)
Msgbox ubound(arr_employee)
End Class
VB6 Exe: main program --> this refers vb6 dll Dll_EmployeeType and Dll_Employee_Methods
This program has form and button on it.
On Button_Click
Dim arr_employee() as Dll_EmployeeType. Employee_Properties
Redim arr_employee(1 to 2)
arr_employee(1). Employee_Id = 1
arr_employee(1). Employee_Name = ?name1?
arr_employee(1). Employee_Address = ?address1?
arr_employee(2). Employee_Id = 2
arr_employee(2). Employee_Name = ?name2?
arr_employee(2). Employee_Address = ?address2?
dim obj as new Dll_Employee_Methods. Cls_Employee
call obj. Display_NoOf_Employees(arr_employee)
error occurs at above line is ?Class does not support an automation or does not support expected interface?
Note: If .Net dll code is in normal class ? no intellicense is displayed in main program
If .Net dll code is in COM class ? intellicense is displayed in main program
But the error is same as above
Case 2:
Vb6 UDT dll is converted to .Net having structure
?Build tlb using COM checkbox as checked
?Add reference of it to Main exe program
?Run program
Throws an error ?Variable uses an automation type not supported in Visual basic? at first line(dim arr_employre() as?..)
|
|
|
|

|
Please any one help me. How to send a mail from application (VB Coding) to E-mail such as Gmail, yahoo.
|
|
|
|

|
Hello everyone. I'm writing an application to use a smart card to fill a process.info username and password. I get the credentials using CredUIPromptForWindowsCredentials and then pass (username,password,domain stringbuilder variables) to CredUnPackAuthenticationBuffer to get a networkcredential username, securepassword and domain. If I use my AD credentials, it works just fine. When I step through the code, I can see the username the is acquired from the smartcard is encrypted possibly??? I'm not really sure how to take the username that the CredUnPackAuthenticationBuffer gives me to use as the username in my process.info. When I run the code now using my smart card, i get an exception "A specified logon session does not exist. It may already have been terminated." How do I get use the username I get from the smart card in my process.info username? I hope this wasn't too confusing because I've been trying to figure this out for a week now...
|
|
|
|

|
Howdie.
I am researching how to use the Unicode version of FindFirstFileEx() in vb.Net and am having a heck of a time getting this to work. I had downloaded an example and it used the standard version, FindFirstFile(). I then modified the code to work with FindFirstFileEx(), instead, and got that to work, too, but only for ANSI characters (Alias "FindFirstFileExA"). But when I attempted to use the Unicode version (Alias "FindFirstFileExW"), it fails miserably. The best I have been able to do is get a non-zero return value from the function (which means it found the folder), but all the returned WFD structure contains are null strings for the folder name and alternate folder name.
I have googled the problem (MSDN is of no help in this regard) and did find one reference on how to alter the function parameters to provide pointers instead of a string and the WFD structure, themselves.
At any rate, here is my code for just the top half that looks for folders. The bottom half deals with searching for files, but it is just a repeat of this example, essentially. If I can get this top half to work with your help, I can certainly get the bottom half to work.
I would have liked to attach a zip containing the project and the test folder I used, but it does not look like attachments are possible, here.
Thanks for any help!
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Friend Class Form1
Inherits System.Windows.Forms.Form
Private Declare Function FindFirstFileExW Lib "kernel32.dll" Alias "FindFirstFileExW" (ByVal lpFileName_IntPtr As IntPtr, ByVal fInfoLevelId As FINDEX_INFO_LEVELS, ByRef lpFindFileData_IntPtr As IntPtr, ByVal fSearchOp As FINDEX_SEARCH_OPS, ByRef lpSearchFilter As Int32, ByVal dwAdditionalFlags As Integer) As Long
Private Declare Function FindNextFileW Lib "kernel32" Alias "FindNextFileW" (ByVal hFindFile As Long, ByRef lpFindFileData As WIN32_FIND_DATA) As Integer
Private Declare Function GetFileAttributesW Lib "kernel32" Alias "GetFileAttributesW" (ByVal lpFileName As String) As Integer
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Integer
Private Declare Function GetLastError Lib "kernel32" Alias "GetLastError" () As Integer
Const MAX_PATH As UInt16 = 260
Const MAXDWORD As UInt64 = 4294967295 Const INVALID_HANDLE_VALUE As Int16 = -1
Const FILE_ATTRIBUTE_ARCHIVE As UInt16 = &H20
Const FILE_ATTRIBUTE_DIRECTORY As UInt16 = &H10
Const FILE_ATTRIBUTE_HIDDEN As UInt16 = &H2
Const FILE_ATTRIBUTE_NORMAL As UInt16 = &H80
Const FILE_ATTRIBUTE_READONLY As UInt16 = &H1
Const FILE_ATTRIBUTE_SYSTEM As UInt16 = &H4
Const FILE_ATTRIBUTE_TEMPORARY As UInt16 = &H100
Public Enum FINDEX_INFO_LEVELS
FindExInfoStandard = 0
FindExInfoBasic = 1
FindExInfoMaxInfoLevel = 2
End Enum
Enum FINDEX_SEARCH_OPS
FindExSearchNameMatch = 0
FindExSearchLimitToDirectories = 1
FindExSearchLimitToDevices = 2
End Enum
Private Structure FILETIME
Dim dwLowDateTime As UInt32
Dim dwHighDateTime As UInt32
End Structure
Private Structure WIN32_FIND_DATA
Dim dwFileAttributes As UInt32
Dim ftCreationTime As FILETIME
Dim ftLastAccessTime As FILETIME
Dim ftLastWriteTime As FILETIME
Dim nFileSizeHigh As UInt32
Dim nFileSizeLow As UInt32
Dim dwReserved0 As UInt32
Dim dwReserved1 As UInt32
<VBFixedString(MAX_PATH), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)> Public cFileName As String
<VBFixedString(14), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=14)> Public cAlternate As String
End Structure
Function StripNulls(ByRef OriginalStr As String) As String
If (InStr(OriginalStr, Chr(0)) > 0) Then
OriginalStr = VB.Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
End If
StripNulls = OriginalStr
End Function
Function FindFilesAPI(ByRef path As String, ByRef SearchStr As String, ByRef FileCount As Integer, ByRef DirCount As Integer) As Long
Dim FileName As String
Dim DirName As String Dim dirNames() As String Dim nDir As Integer = 0
Dim i As Long
Dim hSearchEx As Long Dim WFD As WIN32_FIND_DATA = Nothing Static Cont As Boolean
FindFilesAPI = 0
If VB.Right(path, 1) = "\" Then path = VB.Left(path, Len(path) - 1)
nDir = 0
ReDim dirNames(nDir)
Cont = True
Dim fInfoLevelId As FINDEX_INFO_LEVELS = 0
Dim lpFindFileData As WIN32_FIND_DATA = Nothing
Dim fSearchOp As FINDEX_SEARCH_OPS = 0
Dim lpSearchFilter As Int32 = Nothing
Dim dwAdditionalFlags As Integer = 0
Dim lpFileName_str As String = "\\?\UNC\" & path & "\*"
Dim lpFileName_IntPtr As IntPtr = Marshal.StringToHGlobalAuto(lpFileName_str)
Dim lpFindFileData_Original As WIN32_FIND_DATA = Nothing
Dim lpFindFileData_IntPtr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(lpFindFileData_Original))
Try
Marshal.StructureToPtr(lpFindFileData_Original, lpFindFileData_IntPtr, False)
hSearchEx = FindFirstFileExW(lpFileName_IntPtr, fInfoLevelId, lpFindFileData_IntPtr, fSearchOp, lpSearchFilter, dwAdditionalFlags)
WFD = CType(Marshal.PtrToStructure(lpFindFileData_IntPtr, GetType(WIN32_FIND_DATA)), WIN32_FIND_DATA)
Finally
Marshal.FreeHGlobal(lpFileName_IntPtr)
Marshal.FreeHGlobal(lpFindFileData_IntPtr)
End Try
If hSearchEx <> INVALID_HANDLE_VALUE Then
Do While Cont
System.Windows.Forms.Application.DoEvents()
DirName = StripNulls(WFD.cFileName)
If (DirName <> ".") And (DirName <> "..") And (DirName <> "") Then
Dim FileAttributes As Integer = GetFileAttributesW("\\?\UNC\" & path & "\" & DirName)
If FileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
dirNames(nDir) = DirName
DirCount = DirCount + 1
nDir = nDir + 1
ReDim Preserve dirNames(nDir)
List1.Items.Add(path & "\" & DirName)
End If
End If
Cont = FindNextFileW(hSearchEx, WFD)
Loop
Cont = FindClose(hSearchEx)
If Cont = False Then
MsgBox("Error: " + Str(GetLastError))
End If
End If
End Function
Private Sub Go_cmd_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Go_cmd.Click
Dim SearchPath, FindStr As String
Dim FileSize As Long
Dim NumFiles, NumDirs As Long
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
List1.Items.Clear()
SearchPath = Text1.Text
FindStr = Text2.Text
FileSize = FindFilesAPI(SearchPath, FindStr, NumFiles, NumDirs)
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
End Sub
Private Sub Quit_cmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Quit_cmd.Click
End
End Sub
End Class
|
|
|
|

|
To CodeProject, This is regarding a project that I'm trying to implement - quick chronological file opener script with retrieving 'FileDate' and 'ObjFilePath' and sorting its data into application calendar menu with qick links to exisiting files. Plese give some suggestions on file date and time attributes inserting into form style widget Regards, Nik
|
|
|
|

|
hello guys i have doing some project and since i have new for vb.net 2010. my project is coded in vb.net 2010 and ms access 2007 mdb database. i have DocId, description, date and other fileds in the table.. my querry works for all but. i can't add all characters except integers in the database column DocId. it accepts only integer values. so how can i insert characters in the DocId filed. here is the detail
tables: DocId======Textbox name RefferencNoTxt.Text
Table name = EraDms
database name= data
cmd.CommandText = "INSERT INTO EraDms(DocId,Description,Address,NoOfPages, SendOrReceived, SentDate,ReceivedDate,ForwardedWorkingUnit,Attachements,ForwardedDate,ReceivedBy,DocPath) " & _
" VALUES(" & Me.RefferencNoTxt.Text.ToString & ",'" & Me.DescriptionTextBox.Text & "','" & Me.AddressTextBox.Text & "','" & Me.NoOfPagesTextBox.Text & "','" & Me.SendOrReceievedComboBox.Text & "','" & _
Me.SentDateTextBox.Text & "','" & Me.receivedDate.Text & "','" & Me.ForwardedWorkingUnitTextBox.Text & "','" & Me.AttachementsTextBox.Text & "','" & Me.TextBox6.Text & "','" & Me.ReceivedByTextBox.Text & "','" & Me.DocPathTextBox.Text & "')"
cmd.ExecuteNonQuery()
MessageBox.Show("File Upload Successfull", "ERA-DMS-File Uploader", MessageBoxButtons.OK, MessageBoxIcon.Information)
RefreshData()
cnn.Close()
Else
cmd.CommandText = "UPDATE Eradms " & _
" SET DocId=" & Me.RefferencNoTxt.Text.ToString & _
", Description='" & Me.DescriptionTextBox.Text & "'" & _
", Address='" & Me.AddressTextBox.Text & "'" & _
", NoOfPages='" & Me.NoOfPagesTextBox.Text & "'" & _
", SendOrReceived='" & Me.SendOrReceievedComboBox.Text & "'" & _
", SentDate='" & Me.SentDateTextBox.Text & "'" & _
", ReceivedDate='" & Me.TextBox1.Text & "'" & _
", ForwardedWorkingUnit='" & Me.ForwardedWorkingUnitTextBox.Text & "'" & _
", Attachements='" & Me.AttachementsTextBox.Text & "'" & _
",ForwardedDate ='" & Me.TextBox6.Text & "'" & _
",ReceivedBy ='" & Me.ReceivedByTextBox.Text & "'" & _
",DocPath='" & Me.DocPathTextBox.Text & "'" &
" WHERE DocId=" & Me.RefferencNoTxt.Text.ToString
cmd.ExecuteNonQuery()
RefreshData()
Private Sub RefreshData()
Try
If Not cnn.State = ConnectionState.Open Then
cnn.Open()
End If
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM EraDms", cnn)
Dim dt As New DataTable
da.Fill(dt)
Catch ex As OleDb.OleDbException
End Try
End Sub
best regards
|
|
|
|

|
I'm trying to create a utility to perform a mass update of our Active Directory and all I get is the error, "Server is unwilling to process request."
Below is my code:
Dim de As New DirectoryEntry("GC://DC=us,DC=myCompany,DC=com", "myDomain\MyAdminUsername", "myPassword")
Dim ds As New DirectorySearcher(de)
ds.PropertiesToLoad.Add("department")
ds.SearchScope = SearchScope.Subtree
Dim ue As New DirectoryEntry
ds.Filter = String.Format("(SAMAccountName={0})", Me.tboxUserName.Text)
Try
ue = ds.FindOne.GetDirectoryEntry
For Each sproperty As String In ue.Properties.PropertyNames
debug.print(String.Format("{0}{1} : {2} ", System.Environment.NewLine, sproperty, ue.Properties(sproperty)(0)))
Next
If (ue.Properties.Contains("department")) Then
ue.Properties("department").Value = "IT"
Else
ue.Properties("department").Add("IT")
End If
ue.CommitChanges()
ue.RefreshCache()
ue.Close()
Catch ex As Exception
debug.print (ex.Message)
End Try
The code seems to connect to the LDAP server and retrieve the correct user because I can see valid data being displayed from the ue.Properties.PropertyNames collection.
The error is thrown on the "CommitChanges()" line.
BTW: This demo program is a WinForms .NET 4.0 applicaiton
I have tried it passing no credentials and passing valid domain credentials and I get the same " ... unwilling to process request." error.
What am I doing wrong?
|
|
|
|

|
This question is a new post prompted by my other thread, "The old DoEvents and UserControls". I created a separate thread here, since it is branching off from the old discussion.
In the other thread, it was looking like converting code from supporting DoEvents, to supporting threading might be a big rewrite. But now I am not so sure. I downloaded an example Pause/Resume Thread program from online and that program had a separate class that was threaded. It then communicated to the main form via a delegate.
But I wanted to find out if it was possible to do threading of a procedure that was NOT in a separate class...But one residing in the main form's class, like any other sub. The reason this was important to me, was to cut down on the amount of code rewriting by keeping my existing code in place, and merely adding on additional code to thread one of those main form procedures. My revision to that original threading example seems to say, "yes", to that question. Here is my version of that little demo. It simply runs a counter that counts from 1 to whatever, and when the thread is suspended, the counter halts, until resumed. Since I am new to threading, is there anything wrong with this idea that could end up biting me in the rear?
Here is the code:
Imports System.Threading
Imports System
Public Class Form1
Private Delegate Sub DisplayValueDelegateType(ByVal txt _
As String)
Private m_DisplayValueDelegate As DisplayValueDelegateType
Private m_Thread As Thread
Public Value As Integer = 0
Public Sub DisplayValue(ByVal txt As String)
txtResults.Text = txt
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim new_counter As New Counter(Me, my_number:=1)
m_Thread = New Thread(AddressOf new_counter.Runno)
m_Thread.IsBackground = True
m_Thread.Start()
Button1.Enabled = False
Button2.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
If (m_Thread.ThreadState And ThreadState.Unstarted) _
<> 0 Then
m_Thread.Start()
Else
m_Thread.Resume() End If
Button1.Enabled = False
Button2.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
Debug.WriteLine("Suspending thread")
m_Thread.Suspend()
Button1.Enabled = True
Button2.Enabled = False
End Sub
Public Sub DoSomething(ByVal m_MyForm As Form1, _
ByVal m_DisplayValueDelegate _
As Object)
For loopo = 1 To 10000000
Thread.Sleep(3000)
SyncLock m_MyForm
m_MyForm.Value = m_MyForm.Value + 1
If m_MyForm.InvokeRequired() Then
m_MyForm.Invoke(m_DisplayValueDelegate, _
Str(m_MyForm.Value))
End If
End SyncLock
Next loopo
End Sub
Private Sub Quit_cmd_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Quit_cmd.Click
End
End Sub
End Class
Public Class Counter
Private m_MyForm As Form1
Private Delegate Sub DisplayValueDelegateType( _
ByVal txt As String)
Private m_DisplayValueDelegate As DisplayValueDelegateType
Private m_Number As Integer
Public Sub New(ByVal my_form As Form1, _
ByVal my_number As Integer)
m_MyForm = my_form
m_Number = my_number
m_DisplayValueDelegate = AddressOf _
m_MyForm.DisplayValue
End Sub
Public Sub Runno()
Try
Call Form1.DoSomething(m_MyForm, m_DisplayValueDelegate)
Catch ex As Exception
Debug.WriteLine("Unexpected error in thread " & _
m_Number & vbCrLf & ex.Message)
End Try
End Sub
End Class
|
|
|
|

|
Hey guys,
I want to connect my VB.NET application to the data saved on my webserver's mysql database. Can you please tell me, is it possible or not? Can you give me any hint for further coading? Where should i look for help in this regard?
Or should I consider other language for this pupose?
[Project Details:]
I want users to fill their info on online php form, this info get saved in mysql database. Now i want to insert this info in the .net application's database installed on client's computer.
|
|
|
|

|
Hi again.
I am curious about a problem I am having with DoEvents. Now, I know DoEvents() is old school, and was only included in vb6 because vb6 did not support threading, at least not without a lot of difficulty. But the problem I have, is that I have ported a vb6 program over to vb.Net and there were a fair amount of DoEvents() lines due to a bunch of loops. These DoEvents lines were necessary because I had a Pause button that needs to stop execution when the user desires it.
This worked OK in .Net, too...Until I included a TreeView usercontrol. Now, a fair amount of time is spent in the usercontrol since as the program scans folders, the TreeView is constantly updating to show the progress. In itself, that is a very inefficient way to show progress due to the amount of time processing the TreeView updates. But it looks rather cool as it progresses and I want to keep that look. The problem is that, I know that threading is the way to handle interruption of processing, but on the other hand, I just want this thing running as quickly as possible with the DoEvents lines...I can switch over to threading at some later date.
But no matter where I put the DoEvents lines, they do not let the Pause button Click event to fire. My question is, does entering a usercontrol cause DoEvents in the stack to get cleared out? Or does it simply disregard any DoEvents lines altogether, whether they are inside the user control or not?
Many thanks for any help on this.
|
|
|
|

|
Can anyone please compress the following code? This code is used to make the text property of radiobuttons in a groupbox display values from columns of a dataset.
For Each rad As RadioButton In GroupBox1.Controls
If b > 1 Then
rad.Text = ds.Tables("AddressBook").Rows(a).Item(b)
b = b - 1
End If
Next
a = a + 1
For Each rad As RadioButton In GroupBox2.Controls
If c > 1 Then
rad.Text = ds.Tables("AddressBook").Rows(a).Item(c)
c = c - 1
End If
Next
a = a + 1
For Each rad As RadioButton In GroupBox2.Controls
If d > 1 Then
rad.Text = ds.Tables("AddressBook").Rows(a).Item(d)
d = d - 1
End If
Next
|
|
|
|

|
i can loop through the rows in a dataset using the code below. But how can i loop through the individual items of the same row.
For Each myControl As Control In Me.Controls
If TypeOf myControl Is GroupBox Then
For Each rad As RadioButton In myControl.Controls
rad.Text = ds.Tables("AddressBook").Rows(b).Item(c)
Next
b = b + 1
End If
Next
|
|
|
|

|
Hi,
I'm not able to get the cell value for the selected row in the gridview, the code in the aspx page:
<asp:GridView runat="server" ID="gvElMaster" PageSize="5" Width="100%" ItemType="EMS.Ems_ElMaster"
DataKeyNames="ElMasterID" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
SelectMethod="GetElMaster" HeaderStyle-VerticalAlign="Middle"
HeaderStyle-HorizontalAlign="Center" CaptionAlign="Top" CellPadding="4" GridLines="None" ForeColor="#333333"
OnSelectedIndexChanged="gvElMaster_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:DynamicField DataField="ElName" />
<asp:DynamicField DataField="ElStartRegDate" />
<asp:DynamicField DataField="ElEndRegDate" />
<asp:DynamicField DataField="ElDate" />
<asp:CommandField ShowSelectButton="True" SelectText="Select" CausesValidation="False" InsertVisible="False" ShowCancelButton="False"></asp:CommandField>
</Columns>
</asp:GridView>
code behind:
Public Function GetElMaster() As IQueryable(Of Ems_ElMasterClass)
Return _db.DbSet_ElMasters
End Function
Protected Sub gvElMaster_SelectedIndexChanged(sender As Object, e As EventArgs) Handles gvElMaster.SelectedIndexChanged
MsgBox(gvElMaster.SelectedIndex)
MsgBox(gvElMaster.SelectedValue.ToString)
MsgBox(gvElMaster.SelectedRow.Cells(1).Text)
MsgBox(gvElMaster.SelectedRow.Cells(2).Text)
MsgBox(gvElMaster.SelectedRow.Cells(3).Text)
End Sub
I get empty text from all the cells
Development envirunment is:
- VS 2012
- Asp.net 4.5
- CodeFirst aproach
Thanks for the help
|
|
|
|
 |
Message Automatically Removed
|
|
|
|

|
Hello Friend I am making a GUI for my vpn in visual basic and I am getting a problem when I am using
("perl something.pl" + somehting + something1 + something2)
but when I am using
("perl something.pl something1value something2value")
everything is working fine any solution please
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim IP As String = "xxx.xxx.xxx.xxx"
Dim Username As String = "root"
Dim Password As String = "mypassword"
Dim cmd As Renci.SshNet.SshCommand
Dim connInfo As New Renci.SshNet.PasswordConnectionInfo(IP, Username, Password)
Dim sshClient As New Renci.SshNet.SshClient(connInfo)
Dim something As String = TextBox1.Text
Dim something1 As String = TextBox2.Text
Dim something2 As String = TextBox3.Text
sshClient.Connect()
cmd = sshClient.RunCommand("perl something.pl" +something + something1 + something2)
Label1.Text = cmd.Result
End Sub
End Class
|
|
|
|

|
Hi all.
I have a question about program performance. I have a ton of loops all over the place, and a pause button to pause execution. The pause button is pretty much useless right now as it gets superceded by what I figure are long-winded loops. In an attempt to locate the problem loops, I ended up placing temporary DoEvents lines in all of them. The idea was to see if I could get better performance out of the button. Then, I could remove the majority of those DoEvents that did not impact performance all that much. Unfortunately, all that work resulted in no better performance at all for the button. So I have two questions:
1. Is there some utility that can pinpoint where the majority of a program spends its time, without placing timers or stopwatches everywhere.
2. Are their certain events or API functions that can essentially "shut-down" DoEvents lines?
Thanks for any advice!
|
|
|
|

|
hello everyone, is there anyone could help me to this problem, I have downloaded a module file which is (exifReader), then I apply it to my system code. when I browse an image from a folder or file when I click the a button to show the properties of the image and put it to some textbox, I got this error saying " run time error 9 , Subcription out range", this is the code for showing the properties of the image : Private Sub Command1_Click() If Picture1.Picture = 0 Then MsgBox ("Insert Image First") Else Text6.Text = CommonDialog1.FileName Text3.Enabled = False Dim objexif As New ExifReader objexif.Load (Text6.Text) Text2.Text = objexif.Tag(GPSLongitude) Text3.Text = objexif.Tag(GPSLatitude) Text4.Text = objexif.Tag(GPSInfo) Text5.Text = objexif.Tag(DateTimeOriginal) Text2.Enabled = False Text6.Enabled = False Text3.Enabled = False End If End Sub //******* and this the module part of code where the error shows. Private Function InspectJPGFile() As Boolean Dim i As Long If ExifTemp(0) <> &HFF And ExifTemp(1) <> &HD8 Then InspectJPGFile = False Else ///this line is having error, subscription out of range/// For i = 2 To UBound(ExifTemp) + 1 If ExifTemp(i) = &HFF And ExifTemp(i + 1) = &HE1 Then Offset_to_APP1 = i Exit For End If Next If Offset_to_APP1 = 0 Then InspectJPGFile = False End If Offset_to_TIFF = Offset_to_APP1 + 10 Length_of_APP1 = _ ExifTemp(Offset_to_APP1 + 2) * 256& + _ ExifTemp(Offset_to_APP1 + 3) If Chr(ExifTemp(Offset_to_APP1 + 4)) & Chr(ExifTemp(Offset_to_APP1 + 5)) & _ Chr(ExifTemp(Offset_to_APP1 + 6)) & Chr(ExifTemp(Offset_to_APP1 + 7)) <> "Exif" Then InspectJPGFile = False Exit Function End If InspectJPGFile = True End If
if the codes are not enough to analyze please tell me and I post all the code for exifreader class module, any idea and help are really appreciated. thanks..
by the way I use Visual basic 6.0.. ^_^ jonel
|
|
|
|

|
hi i'm doing the vb project how to record the videos and saving the videos in vb6 please send the codes
|
|
|
|

|
Hello guys,
I posted a question earlier and gut a reply but i dont know how to reply to them, anyway thanks Zoltan and Ron. here is my question, "i have two forms, form1 and form2. i have a button in form1 to show form 2. but when i move form1 and click the button form2 show not in the center. I want form2 always show in the center of form1 even it from another location. thanks. what i got here is this code but it gives me and error in "Me", please help
code
Dim Show_login As New form2
Show_login.StartPosition = FormStartPosition.CenterParent
Show_login.Parent = Me
Show_login.Show()
|
|
|
|

|
Hi All,
i have an Excel which contains 25 columns.Treating it as source file,i need to generate a report which needs to display 3 columns ,also i need to evaluate some calculations and need to display in a newly created column..
Requestname,status and validity.i need to display only these columns in my report.In addition to that i need to calculate the num of requests based on the status/validity values and need to display in seperate column "number of requests".
also we need to calculate the difference between the time based on two columns(format mm/dd/yyyy hh:mm) and put in a seperate column to display.
If this is the wrong window,please suggest me the apt place to post.
|
|
|
|

|
Hi everybody, am going to show you a sample program which enables to print the contents of a datagridview, the program works properly despite a minor error which occurs before the printing is done it says OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT, although it does not prevent the program from meeting the purpose. i would like to share it with you, and atleast we can discus on how to remove that error.
The program is based on the customers table of the Northwind Database.
On my form there is a datagridview named Mydatagridview, A print button called btnPrint
Below is the VB code ..............
Imports System.Data.OleDb
Imports System.Drawing.Printing
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Public Class Form1
Private WithEvents printDocument1 As New PrintDocument
'Used to save left coordinates of columns
Dim arrColumnLefts = New ArrayList()
'Used to save column widths
Dim arrColumnWidths = New ArrayList()
'Used to get and set the datagridview cell height
Dim iCellHeight As Integer = 0
Dim iTotalWidth As Integer = 0
'Used as counter
Dim iCount As Integer = 0
Dim iRow As Integer = 0
'Used to check whether we are printing first page
Dim bFirstPage As Boolean = False
'Used to check whether we are printing a new page
Dim bNewPage As Boolean = False
'Used for the header height
Dim iHeaderHeight As Integer = 0
Dim strFormat = New StringFormat()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As New OleDb.OleDbConnection
con.ConnectionString = "provider=microsoft.jet.oledb.4.0; Data source= " & Application.StartupPath & "\Customers.mdb"
Dim ds As DataSet = New DataSet()
Dim dt As New DataTable
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT CompanyName,ContactName,Address,PostalCode,Phone from Customers2", con)
Me.WindowState = FormWindowState.Maximized
Try
da.Fill(ds, "dt")
da.Fill(ds, "Customers2")
MyDataGridView.DataSource = ds
MyDataGridView.DataMember = "dt"
Catch ex As Exception
MessageBox.Show("Operation failed: " + ex.ToString(), Application.ProductName + " - Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
Return
End Try
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
'Open the print dialogue
Dim MyPrintDialog = New PrintDialog()
MyPrintDialog.Document = printDocument1
MyPrintDialog.UseEXDialog = True
'Get the document
If Windows.Forms.DialogResult.OK = MyPrintDialog.ShowDialog() Then
printDocument1.DocumentName = "Test page print"
printDocument1.Print()
End If
End Sub
Private Sub printDocument1_BeginPrint(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles _
printDocument1.BeginPrint
' MsgBox("starting printpage")
Try
strFormat.Alignment = StringAlignment.Near
strFormat.LineAlignment = StringAlignment.Center
strFormat.Trimming = StringTrimming.EllipsisCharacter
arrColumnLefts.Clear()
arrColumnWidths.Clear()
iCellHeight = 0
bFirstPage = True
bNewPage = True
'Calculating Total Widths
iTotalWidth = 0
For Each dgvGridCol As DataGridViewColumn In MyDataGridView.Columns
iTotalWidth = iTotalWidth + dgvGridCol.Width
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub printDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
printDocument1.PrintPage
Try
'Set the left margin
Dim iLeftMargin As Integer = e.MarginBounds.Left
'Set the top margin
Dim iTopMargin As Integer = e.MarginBounds.Top
'Whether more pages have to print or not
Dim bMorePagesToPrint As Boolean = False
Dim iTmpWidth As Integer = 0
'For the first page to print set the cell width and header height
If bFirstPage = True Then
For Each Gridcol As DataGridViewColumn In MyDataGridView.Columns
iTmpWidth = CType(Math.Floor(CType(CType(Gridcol.Width, Double) / CType(iTotalWidth, Double) * CType(iTotalWidth, Double) * (CType(e.MarginBounds.Width, Double) / CType(iTotalWidth, Double)), Double)), Integer)
iHeaderHeight = CType((e.Graphics.MeasureString(Gridcol.HeaderText, Gridcol.InheritedStyle.Font, iTmpWidth).Height) + 11, Integer)
'Save width and height of headers
arrColumnLefts.Add(iLeftMargin)
arrColumnWidths.Add(iTmpWidth)
iLeftMargin = iLeftMargin + iTmpWidth
Next
End If
'Loop till all the grid rows not get printed
While iRow <= MyDataGridView.Rows.Count - 1
Dim GridRow As DataGridViewRow = MyDataGridView.Rows(iRow)
'Set the cell height
iCellHeight = GridRow.Height + 5
Dim iCount As Integer = 0
'Check whether the current page settings allo more rows to print
If iTopMargin + iCellHeight >= e.MarginBounds.Height + e.MarginBounds.Top Then
bNewPage = True
bFirstPage = False
bMorePagesToPrint = True
Exit While
Else
If bNewPage = True Then
'Draw header
e.Graphics.DrawString("Fibre Requirements", New Font(MyDataGridView.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top - e.Graphics.MeasureString("Customer Summary", New Font(MyDataGridView.Font, FontStyle.Bold), e.MarginBounds.Width).Height - 13)
Dim strDate As String = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString()
'Draw Date
e.Graphics.DrawString(strDate, New Font(MyDataGridView.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - e.Graphics.MeasureString(strDate, New Font(MyDataGridView.Font, FontStyle.Bold), e.MarginBounds.Width).Width), e.MarginBounds.Top - e.Graphics.MeasureString("Customer Summary", New Font(New Font(MyDataGridView.Font, FontStyle.Bold), FontStyle.Bold), e.MarginBounds.Width).Height - 13)
'Draw Columns
iTopMargin = e.MarginBounds.Top
For Each GridCol As DataGridViewColumn In MyDataGridView.Columns
e.Graphics.FillRectangle(New SolidBrush(Color.LightGray), New Rectangle(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iHeaderHeight))
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iHeaderHeight))
e.Graphics.DrawString(GridCol.HeaderText, GridCol.InheritedStyle.Font, New SolidBrush(GridCol.InheritedStyle.ForeColor), New RectangleF(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iHeaderHeight), strFormat)
iCount = iCount + 1
Next GridCol
bNewPage = False
iTopMargin += iHeaderHeight
End If
iCount = 0
'Draw Columns Contents
For Each Cel As DataGridViewCell In GridRow.Cells
If Not IsDBNull(Cel.Value) Then
e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font, New SolidBrush(Cel.InheritedStyle.ForeColor), New RectangleF(CType(arrColumnLefts(iCount), Integer), CType(iTopMargin, Single), CType(arrColumnWidths(iCount), Integer), CType(iCellHeight, Single)), strFormat)
End If
'Drawing Cells Borders
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iCellHeight))
iCount = iCount + 1
Next
End If
iRow = iRow + 1
iTopMargin = iTopMargin + iCellHeight
End While
'If more lines exist, print another page.
If bMorePagesToPrint = True Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
Catch exc As Exception
MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class
|
|
|
|

|
My class is now over. I had an issue with the the assignment. I couldn't get the program to find and display the duplicate random numbers. I've looked for almost two weeks for an answer and I'm hoping that someone here can help me.
This was the assignment:
Present the following report – (you will modify this based on user input and the actual rolls.
Number of dice:2
Number of sides:6
Number of rolls:2
Dice 1 Roll 1 = 5
Dice 2 Roll 1 = 6
Dice 1 Roll 2 = 1
Dice 2 Roll 2 = 1
Number of rolls where all dice were the same: 1
I got everything but the number of rolls where all the dice were the same. Can someone please advise me as to how this should have been done?
Here is a snippet of what I did:
Dim RandomClass As New Random()
Dim vRoll() As Integer ReDim vRoll(nDice)
Dim cntDice As Integer = 0
Dim myArray As New List(Of Integer)
Dim temp As Integer
myArray.Clear()
For i As Integer = 1 To rRoll
For j As Integer = 1 To nDice
temp = RandomClass.Next(1, dSize + 1)
LST_Items.Items.Add("Dice " & j & " Roll " & i & " = " & temp.ToString)
If Not myArray.Contains(temp) Then
cntDice += 1
LBL_Same.Text = cntDice
Else
LBL_Same.Text = "0"
End If
Next
Next
So if anyone is willing to give me advice I would greatly appreciate it.
Thanks!
Troy E Bouchard
|
|
|
|

|
Hi Guys,
Is it possible to have a list/collection of objects that inherit from a single base object without losing Intelli-sense?
Here is an example of what I mean...
Public Class baseblob
Private _position As PointF
Property position
Get
Return _position
End Get
Set(value)
_position = value
End Set
End Property
Sub New()
position = PointF.Empty
End Sub
End Class
Public Class blob
Inherits baseblob
Sub moveRight(ByVal Distance As Single)
position = New PointF(position.X + Distance, position.y)
End Sub
End Class
Public Class Form1
Dim blob As New blob
Dim blobs As New List(Of baseblob)
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
blob.moveRight(10)
MsgBox(blob.position.x)
blobs.Add(blob)
MsgBox(blobs(0).position.x)
blobs(0).moveright(10)
MsgBox(blobs(0).position.x)
End Sub
End Class
... but of course in the above example i get 'moveright' is not a member of 'oopTest.baseblob'
So it wants me to use
Dim blobs As New List(Of Object)
So it will compile and work as intended...
I just wanted to know is there something I'm missing here? Why can't I just let it know that it's a base object and to list all the possible methods/properties etc of the base class and also any objects that inherit the base class? Give me the lot!
To me it doesn't sound like such a hard thing to ask of the compiler/dev environment... why cant it do it ?
:(
modified 14-May-13 0:36am.
|
|
|
|

|
I am currently trying to convert a String that is gotten from an input box to an Integer using the Try Parse method. The integer is then supposed to be used to fill an array named international. Here is the part of the code that pertains to this:
Dim Count As Integer
For Count = 0 To international.Length - 1
international(Count) = Integer.TryParse(InputBox("Keep entering the sales for each month. If nothing typed, will be interpeted as zero", "New data entry"))
Next Count
I am getting the error message: Overload resolution failed because no accessible 'TryParse' accepts this number of arguments.
How do I fix this?
|
|
|
|

|
How to get values from listview and display it to textbox using sql database ?
and then i can update the items in listview using a button..then refresh the listview
after i click the button...all in 1 form
tnx for the help in advance..im just a newbie in vb.net
|
|
|
|

|
Hello.
I am having zero luck finding anything on doing a TreeView1.Nodes.Find() starting from a particular child node. Find() apparently works over the entire tree, and does not let you specify a starting point in the tree.
|
|
|
|

|
Hi,
I'm playing around with encryption in vb.net. The passphrase that I use is stored in code. After building the app the passphrase is not visible anymore. But with the tool CodeReflect.NET I can find the passphrase again. How should I store the passphrase in a safe way?
Cheers,
Frank
|
|
|
|

|
Hi again.
I have a peculiar problem that is somewhat reminiscent of vb6's Eval() function.
Let's say I have a TreeView populated with an entire harddrive's directory structure, and I want to select the node that contains a folder I am looking for. If I use the .Find method, the search could take forever, and I may end up with multiple places in the TreeView where this name is located. If I already have the full path to the correct folder, then I need a quick way to get to the node without having to search the entire tree.
Now, I actually have a quick way of doing this (at least I am confident it will work), but in the process of getting to that solution, I was experimenting with another idea that harks back to that vb6 Eval() function...Sort of. That other idea revolved around selectively expanding a tree branch and testing inside each child node to make sure that the next folder name in my full path could be found there. If so, it would expand that node and continue until all folders in the full path had been exhausted. Theoretically, I would then be at my desired node, which I could then select in the tree. But the problem is that in order to do that, you start at TreeView1.Nodes(0) and do a Find(). Once that node is selected, it gets expanded and you then do a Find() for the second folder, which gets found at Nodes(0).Nodes(x). Moving along in the same fashion, you get to Nodes(0).Nodes(x).Nodes(y), and so on till the task is completed. I think you can see the problem already...Without explicitly setting up Case blocks or If/Else blocks to handle each succession of methods,
Nodes(0)
Nodes(0).Nodes(x)
Nodes(0).Nodes(x).Nodes(y),...
there is no way for the code to handle this problem. And such a folder could lie at the tenth childnode, maybe even the twentieth, or more. The point being, it is a kludge to try to estimate when you should stop providing hard-coded cases and pray that some scenario doesn't exceed that limit.
That is when I was thinking if there was a way to build a string programatically to whatever length I needed it to be, like,
"TreeView1.Nodes(0).Nodes(x).Nodes(y).Expand"
and then convert that string into an actual code statement by having the string "evaluated" as such. Is this possible? As I stated above, I think I found another very elegant solution to my TreeView Find() problem which is simple and quick. But I am curious now, if vb.Net has the ability to turn a string into a code statement, or maybe even multiline text into actual vb.Net code?
|
|
|
|

|
Hello guys,
I'm creating an windows application using vb.net 2010 with mySQL as my database. My question is, if i deploy my application to another computer do i need to install too mySQL program? Thanks
@athan_MaKuBex13
|
|
|
|
 |
|