Reading only part of string

StUnT10011
06-22-2004, 02:26 PM
Okay, here it goes.
I have 3 textboxes, lastNameTxt, firstNameTxt, and depositAmountTxt. When the user clicks cmdAdd it adds all three to a listBox:

John Doe $500.00
Schmo Joe $250.00


mainBox.Items.Add(lastNameTxt.Text & vbTab & vbTab & vbTab & firstNameTxt.Text & vbTab & vbTab & vbTab & "$" & depositAmountTxt.Text & ".00")


then when a user clicks save it saves it as a string to a txt file using a streamwriter and it can be opened again using a streamreader. what i want to know is how would I be able to read only the amount at the end of the string ( eg. the 250.00)??

Iceplug
06-22-2004, 02:50 PM
No, you want to read the whole line... you just need to extract the amount at the end of the string. You can use .ReadLine to read the String, and then use Indexof to find the position of the $. With the position of the S, substring will give you the price.
Ps = Datline.IndexOf("$"c)
S = Datline.Substring(Ps)
:)

StUnT10011
06-22-2004, 03:12 PM
i get it for the most part but what do I dim S and PS as???

NVM dumb question, duh sorry

s_cameron36
06-23-2004, 07:46 AM
or you could store the 3 objects in variables.

strFirst, strLast, dblPrice

Iceplug
06-23-2004, 11:56 AM
Yes, but getting them into those variables is what he wants to know.
Also, declaring the price as a double would require a Convert.ToDouble under Option Strict.

Indices (Indexes) are Integers, and substrings are Strings. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum