Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

data file with spaces, how to store each one in variable VBS

$
0
0

I have a data file such as a txt file and it is like this:

123456

789542

....

these can be any numbers and as many lines as needed. I need to take each number line by line storing them in 6 different variables. Such as:

name = 1

email = 2

these could be dynamic arrays by the columns also:

name = 1,7, ...

Right now my code is only displaying one line and I am not sure how to put each one in the variables like I said above. Can anyone help me with this... my code is below, thanks in advance! This is my first post so I tried.

Sub ButtonTool1_EventClick()
Dim This : Set This = ButtonTool1

Dim arrFileLines()
Dim strLine 
Dim arrStrings
Dim arrPulled
i = 0 

Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFile = objFSO.OpenTextFile("C:\Users\Administrator\My Documents\Nominations.dat", 1) 
Do Until i = 2 '2nd entry, could be 181 for all lines
Redim Preserve arrFileLines(i) 
arrFileLines(i) = objFile.ReadLine 
i = i + 1 
Loop 
objFile.Close 



For Each strLine In arrFileLines
arrStrings = Split(strLine,"  ")
EditBox1.Text = (arrStrings(0))
Next


End Sub 

Right now this code works but only displays the first line of the file which is okay. I just need these to be stored in 6 separate variables. Hopefully I am making sense.





Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>