PureSc0pe Posted April 6, 2004 Posted April 6, 2004 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= Quote It's not impossible, it's Inevitable.
georgepatotk Posted April 6, 2004 Posted April 6, 2004 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.. Quote George C.K. Low
Administrators PlausiblyDamp Posted April 6, 2004 Administrators Posted April 6, 2004 Rather than use the VB6 FileOpen etc. commands you would be much better off using .Net functionality (Streams, StreamReader etc.) However I notice the file looks a lot line an .ini file - if that is the case you may want to have a look here or here. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PureSc0pe Posted April 6, 2004 Author Posted April 6, 2004 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... Quote It's not impossible, it's Inevitable.
georgepatotk Posted April 6, 2004 Posted April 6, 2004 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. Quote George C.K. Low
georgepatotk Posted April 6, 2004 Posted April 6, 2004 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) Quote George C.K. Low
georgepatotk Posted April 6, 2004 Posted April 6, 2004 (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 April 6, 2004 by PlausiblyDamp Quote George C.K. Low
Administrators PlausiblyDamp Posted April 6, 2004 Administrators Posted April 6, 2004 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.INiFile Sample.zip Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PureSc0pe Posted April 6, 2004 Author Posted April 6, 2004 (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 April 6, 2004 by PureSc0pe Quote It's not impossible, it's Inevitable.
Administrators PlausiblyDamp Posted April 6, 2004 Administrators Posted April 6, 2004 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? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PureSc0pe Posted April 6, 2004 Author Posted April 6, 2004 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. Quote It's not impossible, it's Inevitable.
PureSc0pe Posted April 6, 2004 Author Posted April 6, 2004 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? Quote It's not impossible, it's Inevitable.
Administrators PlausiblyDamp Posted April 6, 2004 Administrators Posted April 6, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PureSc0pe Posted April 6, 2004 Author Posted April 6, 2004 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. Quote It's not impossible, it's Inevitable.
georgepatotk Posted April 7, 2004 Posted April 7, 2004 see this code, I had put my effort to write it but some one deleted it.. :oFile.zip Quote George C.K. Low
PureSc0pe Posted April 7, 2004 Author Posted April 7, 2004 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? Quote It's not impossible, it's Inevitable.
georgepatotk Posted April 7, 2004 Posted April 7, 2004 yes, I did. Hope you won't mind. I am not meant to offence you or anything.. Quote George C.K. Low
PureSc0pe Posted April 7, 2004 Author Posted April 7, 2004 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.. :-\ Quote It's not impossible, it's Inevitable.
georgepatotk Posted April 7, 2004 Posted April 7, 2004 just have to change everything back... Thanks for trying.. Change what? and thanks for what? Quote George C.K. Low
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.