stevebakh
03-25-04, 11:47 AM
Hi
Unfortunately, I have to do VB in my first year here.
I'm basically having a problem. We have had to create a very basic program which opens up a text file and stores the info in an array (that's the easy bit) but now I have to get it so that I can search the names in the array and only display names beginning with a certain lette - "S" for example.
The closest thing I could find, during my research, was something known as the "Left function", which would search for the first letter on the left of a string.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctLeft.asp
Firstly, I'm not entirely sure how to implement this, although I've done something along the lines of:
If strSearchResult(33, 1) = Microsoft.VisualBasic.Left(strSearchString, 1) Then
frmOutputDialog.Visible = True
For intRow = 0 To 33
frmOutputDialog.Print strSearchResult(intRow, 0), strSearchResult(intRow, 1)
Next intRow
End If
But I'm a massive newby when it comes to VB and this doesn't work. I think that I need a "Microsoft.VisualBasic" class file, or something along those lines.
Does anybody know of a better method of searching the contents of strings stored in an array for a specific character?
Any help appreciated.
Unfortunately, I have to do VB in my first year here.
I'm basically having a problem. We have had to create a very basic program which opens up a text file and stores the info in an array (that's the easy bit) but now I have to get it so that I can search the names in the array and only display names beginning with a certain lette - "S" for example.
The closest thing I could find, during my research, was something known as the "Left function", which would search for the first letter on the left of a string.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctLeft.asp
Firstly, I'm not entirely sure how to implement this, although I've done something along the lines of:
If strSearchResult(33, 1) = Microsoft.VisualBasic.Left(strSearchString, 1) Then
frmOutputDialog.Visible = True
For intRow = 0 To 33
frmOutputDialog.Print strSearchResult(intRow, 0), strSearchResult(intRow, 1)
Next intRow
End If
But I'm a massive newby when it comes to VB and this doesn't work. I think that I need a "Microsoft.VisualBasic" class file, or something along those lines.
Does anybody know of a better method of searching the contents of strings stored in an array for a specific character?
Any help appreciated.