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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving the contents of a text box to a file 4

Status
Not open for further replies.

hankins1984

IS-IT--Management
Mar 11, 2002
198
GB
can some one please tell me how you the the contebts of a text box to a file.

i have tryed

text1.save ("c:\test.txt")

and nothing happens!!!

thanx Matthew Hankins

Network Technicain @ DGI Hereford
 
that work ace,thanx m8 Matthew Hankins

Network Technicain @ DGI Hereford
 
SWI Do you know how the append a line of data in a .reg file?

eg:
line 1: password= 121212
line 2: port= 121212
line 3: opi=12121212

and i want to replace just line two Matthew Hankins

Network Technicain @ DGI Hereford
 
Never have done that before. Is it just a text file? Also, do you want to append all three lines and have the ability to enter a new code to line 2 every time new data is appended? Swi
 
I answered that above I think, using the api's WritePrivateProfileString and GetPrivateProfileString, although you may need to add a section, for example

[connectioninfo]
password= 121212
port= 121212
opi=12121212


Grant
 
GrantDB i cant get the class file to work,where abouts do you set the file path,and where abouts do you set what part of the file is changed Matthew Hankins

Network Technicain @ DGI Hereford
 
Matthew Hankins,

Having looked at the example, it is a bit unclear. What I should have done is just given you my code, so here it is. Basically when the form loads it sets a path to the ini, although you could do this in the subs

Hope that helps, and sorry for anu confusion. Any problems then let me know

Option Explicit

Private Declare Function WritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, _
ByVal lpString As Any, _
ByVal lpFileName As String) As Long

Private Declare Function GetPrivateProfileString _
Lib "kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Dim strInI As String

Private Sub Form_Load()
strInI = "C:\temp\temp.ini"
End Sub



Private Sub WriteIni_Click()
'write
WritePrivateProfileString "Heading", _
"Key", "Value2", strInI
End Sub

Public Sub ReadIni_Click()
Dim strTmp As String
Dim lngRet As String
strTmp = String$(100, 0)
lngRet = GetPrivateProfileString("Heading", _
"Key", "", strTmp, _
Len(strTmp), strInI)
MsgBox strTmp
End Sub
 
Hi,

I have a question about files. I am making a game in Visual Basic 6.0, and it's a puzzle game. What I want to do is that when a person plays the game I want to permanently save his name as well as his score in a file. I don't know how to save this, and I don't know how to save more than 1 record in the same file...can anyone advise?

Firstly, how do you save a name and a score in a file.

Secondly, how do you save more than 1 of these records in the same file. Everytime i try to save on successive occasions while running the application, it overwrites the previous record.
 
Hi paladin9i0,

Instead of using a sequential access file try using a random access file and a structure for the player's name and score.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top