|
-
Mar 18th, 2007, 08:00 AM
#1
Thread Starter
Addicted Member
Reading text problem
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
-
Mar 18th, 2007, 11:20 AM
#2
Frenzied Member
Re: Reading text problem
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
-
Mar 19th, 2007, 05:43 AM
#3
Thread Starter
Addicted Member
Re: Reading text problem
My problem about split command
I couldn't using split to value while reading from text
-
Mar 19th, 2007, 10:05 AM
#4
Re: Reading text problem
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.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Mar 19th, 2007, 01:57 PM
#5
Re: Reading text problem
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.
-
Mar 19th, 2007, 04:30 PM
#6
Hyperactive Member
Re: Reading text problem
what about replace(allcodeold, "value", "variable") ?
seems easiest to me, but i might be misunderstanding your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|