Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String array into Text File

Status
Not open for further replies.

dstrat6

Programmer
Mar 24, 2008
29
US
Hi Everybody I'm trying to create an array of variables that I get from an OPC Server and put them directly into a text file without have to read from cells on a worksheet, but so far thats the only way I can get it to work. The array goes something like this.

For i = 1 to 5
Cells(7 + i, 3) = Values(i)
Next i

This works, but I would like to do something like this


For i = 1 to 5
s(i) = Values(s(i))
Next i
sStr = Now
str = sStr + s
Print #FileNum, str

Thanks in advance.
Reguards
dstrat6
 




Hi,

Please use TGML codes for your VBA code (search on THIS PAGE)
Code:
 sStr = Now

For i = 1 to 5
   sStr = sSTR & Values(s(i))
 Next i

 Print #FileNum, str


Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
Skip,
keep recieving a type mismatch error. Nothing seems to work; only ween I put it into a cell then print the values from the cell into the txtfile.

Reguards,
dstrat6
 



"type mismatch error."

On what statement?

BTW, your Print# statement that I copied as is, is not the sStr variable. Is that the problem?

Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
Have a look at the Join function:
Print #FileNum, Now & Join(Values, "")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top