Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   Noob Question - Saving [solved] (http://www.programmingforums.org/showthread.php?t=426)

darklord_205 Aug 27th, 2004 8:52 AM

O.K, this may be easiest thing in the world to do, but I don't know how to save data (e.g ComboBox Items) from a VB6 application into a text file (without a flex grid). I can load from a file, and do so using this code:
:

Private Sub Form_Load()
Dim file As String
file = "h:\DL - BRU.txt"
Open file For Input As #1
row = 1
Do Until EOF(1)
Input #1, rm(row)
cmbNo.AddItem rm(row), num(row)
Form3.cmbNo.AddItem rm(row), num(row)
row = row + 1
Loop

Is it possible to save using similiar code?

Pizentios Aug 27th, 2004 9:10 AM

If you are needing to save a variable to disk as a file, add this function to your project (cut & paste) and then use the example below for how to call it.

:

Private Function SaveFile(txtFile, ByVal MyText As String)
  Dim FileNum As Integer

  FileNum = FreeFile()

  Open txtFile For Output As FileNum
  Print #FileNum, MyText;
  Close FileNum
End Function

Say your variable containing data you want saved was named
:

strVarA

You would use like so:
:

SaveFile "D:\File.txt", strVarA

You do not need to use a variable in place of strVarA, you can just put the text you want to save inside of quotes.

:

SaveFile "D:\File.txt", "This is the contents of File.txt"

darklord_205 Aug 27th, 2004 9:57 AM

Thanks

Pizentios Aug 27th, 2004 10:21 AM

No Prob. Welcome to the Forums by the way.


All times are GMT -5. The time now is 4:51 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC