PDA

View Full Version : VisualBasic - array - search parameters


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.

cyberskye
03-26-04, 09:48 PM
awk would be handy now ;)

How do you filter on regular expressions in VB?

stevebakh
03-26-04, 10:06 PM
It's okay - I had help resolving the issue. I was on the right track using left function. :)

How do you filter on regular expressions in VB?
ermmm...?

I think what you're referring to may be "trim" or something like that.. but I'm very very new to VB. It's just something that we had to do - the most complex assignent being to create an array - so we haven't really used many functions or looked into the language in much depth.

Thanks for replying anyway :)