Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help formating a string variable.

Status
Not open for further replies.

RotorTorque

Programmer
Joined
Apr 29, 2007
Messages
100
Location
US
Hi all,
I use string variables in my VB2005 code that combines both the vendor number and name as follows:

VENDOR
123 - Paul's Lumber
456 - Jake's Auto Detailing

How could I make this into two separate variables? for example:

VENDOR NO. VENDOR NAME
123 Paul's Lumber
456 Jake's Auto Detailing


Thanks in advance,
RotorTorque :-)
 
.Substring(Number,Number)

Dim Example As String
Example.Substring(1,2)

-I hate Microsoft!
-Forever and always forward.
 
Dim Val as string = 123 - Paul's Lumber
Dim sVals as string() = Val.Split("-")
Dim sNum as string = sVals(0).Trim
Dim sName as string = sVals(1).Trim

You may want to do more validation and such, but that should get you started.

Senior Software Developer
 
Thank you Sorwen and SiriusBlackOp for your quick response. I will try your suggestions.

RotorTorque :-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top