seperate string
-
Hello, i like to seperate an incoming string to an array. The values are delimited by commas. input string format like "122.23, 232.0, 12.34" I think of using the split function:
Dim inputstr as variant list = split(inputstr,",")
After this i like to put the several values in double format variables. This require some typecasting, right? Does anybody has the syntax for the loop and the typecyasting? I am new to vb.. happy coding, -mark -
Hello, i like to seperate an incoming string to an array. The values are delimited by commas. input string format like "122.23, 232.0, 12.34" I think of using the split function:
Dim inputstr as variant list = split(inputstr,",")
After this i like to put the several values in double format variables. This require some typecasting, right? Does anybody has the syntax for the loop and the typecyasting? I am new to vb.. happy coding, -markHi Mark, not sure which version of VB you're using (VBA, VBCLassic, or VB.Net) for splitting the string in VB.Net...
Dim input as Object = "122.23, 232.0, 12.34"
Dim arrList() as String = CStr(inputString).Split(","c)for casting the remaining items from the stringarray to a double format recursively in VB.Net...
Dim arrCosts(arrList.GetUpperBound(0)) as Double
for i as Int32 = 0 to arrList.Length - 1
arrCosts(i) = Double.Parse(arrList(i).Trim)
nextarrCosts is an array of your Numbers in Double format. hope this helps.
-jim
-
Hi Mark, not sure which version of VB you're using (VBA, VBCLassic, or VB.Net) for splitting the string in VB.Net...
Dim input as Object = "122.23, 232.0, 12.34"
Dim arrList() as String = CStr(inputString).Split(","c)for casting the remaining items from the stringarray to a double format recursively in VB.Net...
Dim arrCosts(arrList.GetUpperBound(0)) as Double
for i as Int32 = 0 to arrList.Length - 1
arrCosts(i) = Double.Parse(arrList(i).Trim)
nextarrCosts is an array of your Numbers in Double format. hope this helps.
-jim
-
Hi Mark, not sure which version of VB you're using (VBA, VBCLassic, or VB.Net) for splitting the string in VB.Net...
Dim input as Object = "122.23, 232.0, 12.34"
Dim arrList() as String = CStr(inputString).Split(","c)for casting the remaining items from the stringarray to a double format recursively in VB.Net...
Dim arrCosts(arrList.GetUpperBound(0)) as Double
for i as Int32 = 0 to arrList.Length - 1
arrCosts(i) = Double.Parse(arrList(i).Trim)
nextarrCosts is an array of your Numbers in Double format. hope this helps.
-jim
-
mmh, by the way do you have an VBA implementation? happy coding, -mark
os win2000 vba office 2003, vc++ 6.0sorry mark, i have absolutely 0 experience with vba and i don't want to give you bad information. this small bit shouldn't be that difficult to translate though. actually, thinking about it, in vba are there any other data types other than variant? or am i thinking of vb script...
-jim
-
Hello, i like to seperate an incoming string to an array. The values are delimited by commas. input string format like "122.23, 232.0, 12.34" I think of using the split function:
Dim inputstr as variant list = split(inputstr,",")
After this i like to put the several values in double format variables. This require some typecasting, right? Does anybody has the syntax for the loop and the typecyasting? I am new to vb.. happy coding, -mark -
dim str as string
For Each str in list
Value = CDbl(str)
NextThis should probably work
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Hi, confusing.. So how must be the code to read out the input string into the the double type text fields as shown below?
Dim input As Variant Dim value(1 to 3) AS double input = "122.23, 232.0, 12.04" . . . labelx.caption = value(1) //double 122.23 labely.caption = value(2) //double 232.0 labelz.caption = value(3) //double 12.04
happy coding, -mark
os win2000 vba office 2003, vc++ 6.0 -
Hi, confusing.. So how must be the code to read out the input string into the the double type text fields as shown below?
Dim input As Variant Dim value(1 to 3) AS double input = "122.23, 232.0, 12.04" . . . labelx.caption = value(1) //double 122.23 labely.caption = value(2) //double 232.0 labelz.caption = value(3) //double 12.04
happy coding, -mark
os win2000 vba office 2003, vc++ 6.0 -
Dim i as integer
dim str as string = Split(input,",")For i = 1 to 3
value(i) = CDbl(str(i-1))
Next
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
input = "122.23, 232.0, 12.04" Dim i As Integer Dim str() As String str = Split(input, ",") For i = 1 To 3 value(i) = CDbl(str(i - 1)) Next Labelx.Caption = value(1) // 12223 Labely.Caption = value(2) // 2320 Labelz.Caption = value(3) // 1204
Yeah, this works. But why are the output values no float variables? happy coding, -mark
os win2000 vba office 2003, vc++ 6.0