Languages :: Visual Basic :: How to create a txt file in Visual Basic but the data must have equal number of bytes |
|||
| By: collegeBoy |
Date: 11/05/2003 00:00:00 |
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 | 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 | 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 | 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 | Type : Comment |
|
| Thanks a lot for ur help, do appreciate it .... |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








