Hi all;
I have text which contain data like below
Hello
value1=2
value2=3
value3=4
i want to read these data and put them different variables.
For example my variables wil be
variable1=2
variable2=3
variable3=4
Thanks
Printable View
Hi all;
I have text which contain data like below
Hello
value1=2
value2=3
value3=4
i want to read these data and put them different variables.
For example my variables wil be
variable1=2
variable2=3
variable3=4
Thanks
Not quite sure what you mean here, but here goes:
vb Code:
MyVariable1 = Value1 MyVariable2 = Value2
you might want to look into using arrays for the text values and the variables.
vb Code:
'used as a counter to loop through the array elements Dim Ctr as Long Dim MyVar(5) As Variable Dim MyValue(5) As Long 'this array has 6 elements to it (arrays are zero based) For Ctr = 0 To MyVar(5) MyVar(Ctr) = MyValue(Ctr) 'assuming the number of values to save is 6 Next
My problem about split command
I couldn't using split to value while reading from text
Split splits strings. If the values are other types you'll have to convert.Code:Dim s() As String, i As Integer
Open "C:\File.txt" For Input As #1
s = Split(Input(LOF(1), 1), vbCrLf)
Close #1
IntegerVariable1 = CInt(s(0))
LongVariable2 = CLng(s(1))
DateVariable3 = CDate(s(2))
'etc.
Since VAL() is available in VB6, the easiest way would be to obtain VAL(Right(Text,1)) where Text changes from "Hello" to "Value1=1" to "Value2=2" to "Value3=3".
The returned values in each case are 0, 1, 2, and 3.
what about replace(allcodeold, "value", "variable") ?
seems easiest to me, but i might be misunderstanding your question.