Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Registry & File Input / Output

Post new topic   Reply to topic
auto-saving & sequential filename?
View previous topic :: View next topic  
Author Message
sundaecone
Newbie


Joined: 03 Jun 2005
Posts: 2

PostPosted: Jun 3rd, 2005 02:01 AM    Post subject: auto-saving & sequential filename? Reply with quote

i was wondering if this is possible in VB..

here's my situation:
i have a microcontroller connected at com1.. my PC sends info to the microcontroller then the microcontroller manipulates the sent info, afterwards the microcontroller sends the manipulated info to my PC, my VB project accepts this info and displays it..

what i want to do:
1.) i want the said manipulated info to be stored first into an array then saved *automatically* into a text file after a certain *end of file to be saved* signal is sent by the microcontroller. is this possible?
2.) also, would it be possible that the VB program would save the text file using sequential filenames? (ie. file01.txt, file02.txt, file03.txt etc)

why i want it?
because, our project requires a series of testing and we want to test the system with all possible scenarios before looking at the final data..

thanks in advance! =D
_________________
Eternally Grateful,

SundaeCone
Back to top
View user's profile Send private message
rbgCODE
Regular


Joined: 11 Nov 2004
Posts: 54
Location: Manchester CT

PostPosted: Jun 3rd, 2005 10:54 AM    Post subject: Reply with quote

Here is the code for the sequential file names

Code:

Public Function makeFileName() As String
Dim curDate' this is the prefix so make it what you want.
Dim curStep
 curDate = Format(Date, "YYYYMMDD")
 curStep = "001"
 While FileExist(App.Path & "\" & curDate & curStep & ".TXT") = True
  curStep = Val(curStep) + 1
  curStep = makeClen(CStr(curStep), 3)
 Wend
 If Len(curStep) = 2 Then curStep = "0" & curStep
 makeFileName = curDate & curStep & ".TXT"
End Function


and here is the code to save it to the text file.

Code:

Public Function addTXT(theStr As String, TheFile As String)
Dim ff
 ff = FreeFile
 TheFile = App.Path & "\" & TheFile
 Open TheFile For Append As #ff
  Write #ff, theStr
 Close #ff
End Function

_________________
'><>
'rBg
'><>
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Registry & File Input / Output All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic