Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How to find if a list of data contains a specific string - Visual Basic Problem?
I am trying to find a specific name in a list of names. The user will enter the name into a textbox and it will search though the list to find it.
My names are set out like this:
Adam James, 402521
Max Hastings, 410211
Michael Burleigh, 542112
and I need to find them and then split off the phone number. I got the last bit working and its splitting off the number but at the moment I have to type out the whole name and the number. I need it so I can just type"Adam James" not "Adam James, 402521"
Here is my code:
names is the list
Dim thename As String = txtFindEntryName.Text
Dim str As String
If names.Contains(thename) Then
str = thename
This finds the name from the list fine but only if the name is exactly the same how can I find it if its not?
Thanks for your help in advance.
2 Answers
- garbo7441Lv 71 decade agoFavorite Answer
You are probably after the 'Instr' function. Here is a link to a tutorial:
- ?Lv 45 years ago
the 1st element to do could be to refactor the code slightly. This code is functionally precisely comparable to your modern code yet reorganized (refactored): Dim sw As StreamWriter sw = document.AppendText("itemdata.csv") for i = 0 to fourteen call processLine(sw, i) next MsgBox("records Written to document") sw.close() functionality processLine(sw, num) merchandise=products(num) fee = fee(num) sw.WriteLine(products & "," & fee) end functionality it particularly is now uncomplicated to characteristic a try into the code in one place that does what you prefer. in the processLine functionality you are able to upload the try. it is not obtrusive out of your question if the article and value could be empty or only one or the different yet as quickly as we in simple terms wanted to be certain that there is a cost you are able to exchange the functionality like this: functionality processLine(sw, num) merchandise=products(num) fee = fee(num) if fee <>"" then sw.WriteLine(products & "," & fee) end if end functionality final word: in case you declare sw as a international variable then you particularly do not might desire to pass it into the processLine functionality each and every time. stable success!