Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[VB6] - Help - Writing into a Text File.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Glіtch
Expert Cheater
Reputation: 0

Joined: 14 Dec 2008
Posts: 126

PostPosted: Mon Feb 16, 2009 9:28 am    Post subject: [VB6] - Help - Writing into a Text File. Reply with quote

Yea well I'm currently in the process of making a program using Visual Basic 6.0. To explain, the program is going to be a "Tool" that people will be able to use to help them with Scripting. The purpose is for a commonly known program called RSBot. I'm making a Tool so that Scripters will be able to record Coordinates that they found and enter them, while the Program writes the coords in code in a text file. I can get it to write the Code into a text file, but I'm trying to make it a little more advanced. Here's what I have so far:

Code:

Private Sub Command1_Click()
Dim opened As Long
If opened = 0 Then
    Open "C:\RSBotScriptCoords1.txt" For Output As #1
    opened = 1
    Write #1, Text1.Text
Else
    Write #1, Text1.Text
End If
End Sub


What I'm trying to do is make it so that when the scripter enters the coordinates of the player position, it makes the file then writes the information until the scripter decides to end it in another command. The problem is that when I click the Button it doesn't seem to record the
Code:
 opened = 1
part of it.

Any help?

_________________
It's been ages.
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Mon Feb 16, 2009 10:28 am    Post subject: Reply with quote

Nvm... Cause the variable is not declared globally.

Put Dim opened at the top or in a module declare as global opened
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Mon Feb 16, 2009 3:05 pm    Post subject: Re: [VB6] - Help - Writing into a Text File. Reply with quote

Nahte108 wrote:
Yea well I'm currently in the process of making a program using Visual Basic 6.0. To explain, the program is going to be a "Tool" that people will be able to use to help them with Scripting. The purpose is for a commonly known program called RSBot. I'm making a Tool so that Scripters will be able to record Coordinates that they found and enter them, while the Program writes the coords in code in a text file. I can get it to write the Code into a text file, but I'm trying to make it a little more advanced. Here's what I have so far:

Code:

Private Sub Command1_Click()
Dim opened As Long
If opened = 0 Then
    Open "C:\RSBotScriptCoords1.txt" For Output As #1
    opened = 1
    Write #1, Text1.Text
Else
    Write #1, Text1.Text
End If
End Sub


What I'm trying to do is make it so that when the scripter enters the coordinates of the player position, it makes the file then writes the information until the scripter decides to end it in another command. The problem is that when I click the Button it doesn't seem to record the
Code:
 opened = 1
part of it.

Any help?


1. Why are you using the datatype long as a boolean?
2. Why do you use else when you use the same code to write to the file whenever the file is allreday open or not.
3. As dns said, declear the var outside of the klickevent or the variable will be set to 0 everytime the event is called.

Code:

//For instnace under general or in a module.
Dim opened As Boolean


Code:

Private Sub Command1_Click()
If opened = 0 Then
    Open "C:\RSBotScriptCoords1.txt" For Output As #1
    opened = 1
End If
Write #1, Text1.Text
End Sub

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
SoccaBallDude
Master Cheater
Reputation: 1

Joined: 29 Aug 2008
Posts: 263

PostPosted: Mon Feb 16, 2009 3:38 pm    Post subject: Reply with quote

If I understood what you want correctly, when a button is pressed, you want it to continuously send text to a text file until another button is pressed.

Code:
Private Sub Command1_Click()
    Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
    Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
    Open App.Path & "\RSBotScriptCoords1.txt" For Append As #1
    Print #1, Text1.Text
    Close #1
End Sub


Even if that's not exactly what you want, appending to the file is easier, as it simply adds to the end of the file. Also, using "print" instead of "write" removes the quotes from whatever you send to the text file. Finally, you should always close the file when your done with it, or else you will have to close the application before you see anything written to the text file.

edit: change the app.path part if you want, I was just using that while I was testing it.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites