visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Visual Basic :: How to create a txt file in Visual Basic but the data must have equal number of bytes


By: collegeBoy U.S.A.  Date: 11/05/2003 00:00:00  English  Points: 75 Status: Answered
Quality : Excellent
Hi im new to VB and i would like to know how to create a file (text file). But the data itself have to be 8 character long when it is written to the txt file....

the txt file should look liket this

SPED----,VELOCITY,ACC-----
456, 567, 78
---8----,---8----,---8----


so they all have equal number of bytes. btw sorry if my english is really bad, forgive me for that but i need help fast... It's for my assignment.... :(
By: VGR Date: 11/05/2003 21:25:00 English  Type : Assist
1) fp=fopen('filename','w'); to create the file
2) a while loop writing lines
3) each line written has to contain left-padded values up to 8 length
4) fclose(fp); to flush&close the file
By: jyokum Date: 11/05/2003 22:18:00 English  Type : Assist
Since this is homework, your not going to get a full solution (it violates the rules of EE)

For VB, you could setup a user defined type, to hold all your variables (speed, velocity, etc..) and dim them as strings with a length of 8. Use the Open & Put commands to write the data to the file. Use a Random file type so you can write the data with fixed length.
By: loquens Date: 11/05/2003 22:25:00 English  Type : Answer
try this:

Dim strTmp As String
Open "c:\temp\a.txt" For Output As #1
strTmp = ""
strTmp = Format("SPED", "!@@@@@@@@,") & Format("VELOCITY", "!@@@@@@@@,") & Format("ACC", "!@@@@@@@@")
Print #1, strTmp
strTmp = Format("456", "@@@@@@@@,") & Format("567", "@@@@@@@@,") & Format("678", "@@@@@@@@")
Print #1, strTmp
Close #1

By: mcrayeps Date: 21/05/2003 22:41:00 English  Type : Comment
Thanks a lot for ur help, do appreciate it ....


Do register to be able to answer

EContact
browser fav
page generated in 299.044850 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page