Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a program to login into TeamSpeak. However I want what is entered into the 3 TextBox's to be saved to a .ini or .txt file (w/e is easier) Then when you choose which server to log into (combobox1 -- serv1, serv2 etc...)

It reads which username and pass you had used for that server and puts it into the textbox. Also, how can I make the password textbox show as *******

 

[serv1]

NickName=

LoginName=

Password=

 

[serv2]

NickName=

LoginName=

Password=

 

[serv3]

NickName=

LoginName=

Password=

 

[serv4]

NickName=

LoginName=

Password=

 

[serv5]

NickName=

LoginName=

Password=

 

[serv6]

NickName=

LoginName=

Password=

It's not impossible, it's Inevitable.
Posted

Dim thehost As String
           FileOpen(1, Application.StartupPath & "/" & "Host.ini", OpenMode.Input)
           Input(1, thehost)
           txtServer.text = thehost
           FileClose(1)

 

This is for the text file reading. I think it is a sufficient source code for you to continue with file writing.

 

It is very simple, check it out..

George C.K. Low

Posted
Didn't get much out of eithe of those...not sure if you knew, but I'm using Visual Studio .Net... I don't care if it's a .ini or a .txt as long as it works...
It's not impossible, it's Inevitable.
Posted

u do it in this way Pure,

 

if you have 6 servers, create 6 .txt file for it.

named it with

 

Server1.txt

Server2.txt

Server3.txt

Server4.txt

Server5.txt

Server6.txt

 

drag and drop a combobox, add items as below:

Server1

Server2

Server3

Server4

Server5

Server6

 

So, as for the processes in the combobox do as below:

 

    Private Sub ComboBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
       Select Case ComboBox1.Text
           Case "Server1"
           Dim thehost As String
           FileOpen(1, Application.StartupPath & "/" & "Server1.txt", OpenMode.Input)
           Input(1, thehost)
           messagebox.show(thehost)
           FileClose(1)

           Case "Server2"
           Dim thehost As String
           FileOpen(1, Application.StartupPath & "/" & "Server2.txt", OpenMode.Input)
           Input(1, thehost)
           messagebox.show(thehost)
           FileClose(1)

           Case "Server3"
           Dim thehost As String
           FileOpen(1, Application.StartupPath & "/" & "Server3.txt", OpenMode.Input)
           Input(1, thehost)
           messagebox.show(thehost)
           FileClose(1)

       End Select
   End Sub

 

try to look into this code. might be helpful for you. If needed, I could send another one for file reading and writing.

George C.K. Low

Posted

text file format: nick, username, password

example of the content in Server1, Server2, Server3, ... is as below:

 

georgepatotk, patotk, 12345

 

so, read the file in the below shown format

       FileOpen(1, Application.StartupPath & "/" & "Server1.txt", OpenMode.Input)
       Dim theNick As String
       Input(1, thenick)
       MessageBox.Show(theNick) 'assign to whereever you like

       Dim theUserName As String
       Input(1, theUserName)
       MessageBox.Show(theUserName) 'assign to wherever you like

       Dim thePassword As String
       Input(1, thePassword)
       MessageBox.Show(thePassword) 'assign to wherever you like
       FileClose(1)

George C.K. Low

Posted (edited)
ok, seems I am still wondering whether you understand what I had written, now I had written it into a simple program, check it out. Hope that I could help you. Edited by PlausiblyDamp

George C.K. Low

Posted (edited)
Here's a really quick sample knocked up using the Mentalis link. Looks ugly but will read the values into textboxes and save you changes back.

Works with the file layout you specified.

 

 

That helped a great deal. However, now it doesn't show the names in the combobox drop down menu. Since it's not showing the names, I can't see if the recording thing is working.... No errors, just not working.

Edited by PureSc0pe
It's not impossible, it's Inevitable.
Posted
Could you post your code. The sample I did happily populated the listbox and would write the changes back.

If you step through the code in the debugger do the values look like what you would expect?

 

 

OK, here's what I guess the problem is. In Form1_Load this code causes it to delete the names from the combobox...

 

ComboBox1.DataSource = ini.GetSectionNames()

 

I had put that in there because it was in the file you posted in form1_load.

When I take it out, it works. What I don't get though is how it is remembering what I type in the textbox's and not recording it in the textfile.

It's not impossible, it's Inevitable.
Posted

This is what I'm using to write to the file:

 

If CheckBox1.Checked = True Then

ini.Write(ComboBox1.SelectedItem.ToString, "NickName", TextBox1.Text)

ini.Write(ComboBox1.SelectedItem.ToString, "LoginName", TextBox2.Text)

ini.Write(ComboBox1.SelectedItem.ToString, "Password", TextBox3.Text)

End If

 

 

 

Also, How would I make textbox3 (the password field) use ******* instead of the actual password?

It's not impossible, it's Inevitable.
Posted
If you step through the code what happens? Does it execute the code you are using to write the file?

Also textboxes have a passwordchar property - set that to whatever you want displayed instead of the real text.

 

 

Password Char worked. Now the code I showed you should've worked right? If it's not writing to a file though, how is it remembering what is typed in even after the program is closed.

It's not impossible, it's Inevitable.
Posted
see this code' date=' I had put my effort to write it but some one deleted it.. :o[/quote']

 

 

That's not even close to what I want it to do...Did you read what PlausiblyDamp and I had been talking about?

It's not impossible, it's Inevitable.
Posted
yes, I did.

Hope you won't mind. I am not meant to offence you or anything..

 

not offended, just have to change everything back... :( Thanks for trying.. :-\

It's not impossible, it's Inevitable.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...