Click here to Skip to main content
15,891,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
I need to read data from text file (one strLine) in a way that first string is Date and time format, second separated with vbTab, third separated with vbTab and soo on until the end of line(13th string). I succeed to read Date and Time(when it is only Date an time string within text file), but when i try to read it with rest strings it reads only first string.

When I read only Date and Time (first string) it reads alright, but when i have second string separated with vbTab then it reads second string alright, but in Date and Time String writes zero(not read good). Probably problem with locations. 

To short my problem: i have 14 strings separated with vbTab in one row and how can i read that in 14 different variables ?


What I have tried:

VB
strLine = objFile.ReadLine
	
	VarLoc1 = InStr(strLine)
	Set Var1 = HMIRuntime.Tags("DATE")
	Var1.Value = CDate(Right(strLine, Len(strLine) - VarLoc1))				
	Var1.Write 
	
	Wscript.Echo strLine
	
	VarLoc2 = InStr(strLine, vbTab)
	Set Var2 = HMIRuntime.Tags("VALUE")
	Var2.Value = CDbl(Right(strLine, Len(strLine) - VarLoc2))				
	Var2.Write
Posted
Updated 11-Jan-19 2:58am
v3
Comments
Afzaal Ahmad Zeeshan 16-Dec-18 17:49pm    
And the problem with this is?
ChauhanAjay 16-Dec-18 17:50pm    
Hope the below link helps
https://stackoverflow.com/questions/3117121/reading-and-writing-value-from-a-textfile-by-using-vbscript-code
Member 14091592 17-Dec-18 3:53am    
thanks, but this is only when u have one value(variable) to read/write, i suceeed that, but the problem is when i have row with 14 variables separated with vbTab.
ChauhanAjay 17-Dec-18 16:54pm    
Read the whole file in one variable and then split it at the vbTab. In this case you will have an array of all your values then you can use the array and get the values of different variables. Hope this helps.
Member 14091592 17-Dec-18 17:13pm    
will this work if i have three rows, first and third are some text that i don't need, so all variables are in second row. maybe if u have some example of code i will appreciate. thanks man!

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900