Results 1 to 10 of 10
  1. #1
    tremaster's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    523
    Reputation
    10
    Thanks
    95
    My Mood
    Amazed

    [Solved]Save preferences

    hey i am making a project when you get into form 2 It needs to save all the stuff that's in there like check boxes checked, text boxes stuff like that

  2. #2
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    I don't understand what you're doing ? Are you saying that when you get on to Form 2, all the stuff on the Form1 is to be saved ??

    Unless you are clear on what you exactly want to do, take a look at this thread:


    https://www.mpgh.net/forum/33-visual-...gs-solved.html

    It covers almost all the savesettings methods.

  3. #3
    Lakshay's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    www.MPGH.net // General // Crossfire
    Posts
    4,545
    Reputation
    335
    Thanks
    1,102
    My Mood
    Angelic
    I didnt get what u emant to say dude.......Can u explain a bit more eh?

  4. #4
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy
    Use the my.settings or an .ini file.
    -Rest in peace leechers-

    Your PM box is 100% full.

  5. The Following User Says Thank You to Zoom For This Useful Post:

    Hassan (06-04-2010)

  6. #5
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by hejsan View Post
    Use the my.settings or an .ini file.
    how can i create a .ini file?

  7. #6
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by Sixx93 View Post
    how can i create a .ini file?
    First create a module and put the following function in it (Reads settings from an INI file):

    Code:
    Public Function ReadIniValue(ByRef INIpath As String, ByRef KEY As String, ByRef Variable As String) As String
    		Dim NF As Short
    		Dim Temp As String
    		Dim LcaseTemp As String
    		Dim ReadyToRead As Boolean
            NF = FreeFile()
    		ReadIniValue = ""
    		KEY = "[" & LCase(KEY) & "]"
    		Variable = LCase(Variable)
            FileOpen(NF, INIpath, OpenMode.Binary)
    		FileClose(NF)
    		SetAttr(INIpath, FileAttribute.Archive)
            FileOpen(NF, INIpath, OpenMode.Input)
    		While Not EOF(NF)
    			Temp = LineInput(NF)
    			LcaseTemp = LCase(Temp)
    			If InStr(LcaseTemp, "[") <> 0 Then ReadyToRead = False
    			If LcaseTemp = KEY Then ReadyToRead = True
    			If InStr(LcaseTemp, "[") = 0 And ReadyToRead = True Then
    				If InStr(LcaseTemp, Variable & "=") = 1 Then
    					ReadIniValue = Mid(Temp, 1 + Len(Variable & "="))
                        FileClose(NF)
                        Exit Function
    				End If
    			End If
    		End While
    		FileClose(NF)
    	End Function
    Then add this function (Writes settings to INI file):

    Code:
    Public Function WriteIniValue(ByRef INIpath As String, ByRef PutKey As String, ByRef PutVariable As String, ByRef PutValue As String) As Object
    		Dim Temp As String
    		Dim LcaseTemp As String
    		Dim ReadKey As String
    		Dim ReadVariable As String
    		Dim LOKEY As Short
    		Dim HIKEY As Short
    		Dim KEYLEN As Short
    		Dim VAR As Short
    		Dim VARENDOFLINE As Short
    		Dim NF As Short
    		Dim X As Short
    		
    AssignVariables: 
    		NF = FreeFile
    		ReadKey = vbCrLf & "[" & LCase(PutKey) & "]" & Chr(13)
    		KEYLEN = Len(ReadKey)
    		ReadVariable = Chr(10) & LCase(PutVariable) & "="
    		
    EnsureFileExists: 
    		FileOpen(NF, INIpath, OpenMode.Binary)
    		FileClose(NF)
    		SetAttr(INIpath, FileAttribute.Archive)
    		
    LoadFile: 
    		FileOpen(NF, INIpath, OpenMode.Input)
    		Temp = InputString(NF, LOF(NF))
    		Temp = vbCrLf & Temp & "[]"
    		FileClose(NF)
    		LcaseTemp = LCase(Temp)
    		
    LogicMenu: 
    		LOKEY = InStr(LcaseTemp, ReadKey)
    		If LOKEY = 0 Then GoTo AddKey
    		HIKEY = InStr(LOKEY + KEYLEN, LcaseTemp, "[")
    		VAR = InStr(LOKEY, LcaseTemp, ReadVariable)
    		If VAR > HIKEY Or VAR < LOKEY Then GoTo AddVariable
    		GoTo RenewVariable
    		
    AddKey: 
    		Temp = Left(Temp, Len(Temp) - 2)
    		Temp = Temp & vbCrLf & vbCrLf & "[" & PutKey & "]" & vbCrLf & PutVariable & "=" & PutValue
    		GoTo TrimFinalString
    		
    AddVariable: 
    		Temp = Left(Temp, Len(Temp) - 2)
    		Temp = Left(Temp, LOKEY + KEYLEN) & PutVariable & "=" & PutValue & vbCrLf & Mid(Temp, LOKEY + KEYLEN + 1)
    		GoTo TrimFinalString
    		
    RenewVariable: 
    		Temp = Left(Temp, Len(Temp) - 2)
    		VARENDOFLINE = InStr(VAR, Temp, Chr(13))
    		Temp = Left(Temp, VAR) & PutVariable & "=" & PutValue & Mid(Temp, VARENDOFLINE)
    		GoTo TrimFinalString
    		
    TrimFinalString: 
    		Temp = Mid(Temp, 2)
    		Do Until InStr(Temp, vbCrLf & vbCrLf & vbCrLf) = 0
    			Temp = Replace(Temp, vbCrLf & vbCrLf & vbCrLf, vbCrLf & vbCrLf)
    		Loop 
    		
    		Do Until Right(Temp, 1) > Chr(13)
    			Temp = Left(Temp, Len(Temp) - 1)
    		Loop 
    		
    		Do Until Left(Temp, 1) > Chr(13)
    			Temp = Mid(Temp, 2)
    		Loop 
    		
    OutputAmendedINIFile: 
    		FileOpen(NF, INIpath, OpenMode.Output)
    		PrintLine(NF, Temp)
    		FileClose(NF)
        End Function
    To demonstrate its working:

    Create a textbox and a button on the form. Now double click the button to open its click event code. Now add the following code to it:


    Code:
    WriteIniValue("D:\IniTest.ini", "Default", "Text", (TextBox1.Text))
    This will save the text of the Textbox1 into the ini file "D:\IniTest.ini" with the category "Default" and variable "Text".

    Now double click the form or simply goto its load event code. There, add the following line of code:


    Code:
    TextBox1.Text = ReadIniValue("D:\IniTest.ini", "Default", "Text")
    This will read the text from the ini file "D:\IniTest.ini" with the category "Default" and variable "Text" and write it into Textbox1.

    Hope this helps !!

  8. The Following 2 Users Say Thank You to Hassan For This Useful Post:

    Sixx93 (06-05-2010),Zoom (06-04-2010)

  9. #7
    hopefordope's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Herndon,VA
    Posts
    264
    Reputation
    9
    Thanks
    86
    My Mood
    Psychedelic
    hey flame i was wondering what is the address or path for you desktop

    i.e C://desktop

    Press Thank You[IMG]https://i45.tinypic.com/2hg8w0n.jpghttps://img1.UploadScreensho*****m/images/main/2/3203234450.jpg[/IMG]










    My Releases
    Injector 3G
    Injector 2G
    Injector 1G
    Super Spammer
    CA Cleaner
    My Tutorials
    How to Make a real Injector(PerX)
    How to Make a Calculator(leeched)

  10. #8
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Put this code in:

    Code:
    Dim stream1 as system.io.streamwriter = new system.io.streamwriter(my.computer.filesystem.specialdirectories.desktop & "\example.ini")
    stream1.write("preferenceshere")
    stream1.close

  11. #9
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by hopefordope View Post
    hey flame i was wondering what is the address or path for you desktop

    i.e C://desktop
    Just put this:

    My.Computer.Filesystem.SpecialDirectories.Desktop & "\Example.ini"

    @Lolland: Only filename is needed. Stream will be created automatically.

  12. #10
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by FLAMESABER View Post
    First create a module and put the following function in it (Reads settings from an INI file):

    Code:
    Public Function ReadIniValue(ByRef INIpath As String, ByRef KEY As String, ByRef Variable As String) As String
    		Dim NF As Short
    		Dim Temp As String
    		Dim LcaseTemp As String
    		Dim ReadyToRead As Boolean
            NF = FreeFile()
    		ReadIniValue = ""
    		KEY = "[" & LCase(KEY) & "]"
    		Variable = LCase(Variable)
            FileOpen(NF, INIpath, OpenMode.Binary)
    		FileClose(NF)
    		SetAttr(INIpath, FileAttribute.Archive)
            FileOpen(NF, INIpath, OpenMode.Input)
    		While Not EOF(NF)
    			Temp = LineInput(NF)
    			LcaseTemp = LCase(Temp)
    			If InStr(LcaseTemp, "[") <> 0 Then ReadyToRead = False
    			If LcaseTemp = KEY Then ReadyToRead = True
    			If InStr(LcaseTemp, "[") = 0 And ReadyToRead = True Then
    				If InStr(LcaseTemp, Variable & "=") = 1 Then
    					ReadIniValue = Mid(Temp, 1 + Len(Variable & "="))
                        FileClose(NF)
                        Exit Function
    				End If
    			End If
    		End While
    		FileClose(NF)
    	End Function
    Then add this function (Writes settings to INI file):

    Code:
    Public Function WriteIniValue(ByRef INIpath As String, ByRef PutKey As String, ByRef PutVariable As String, ByRef PutValue As String) As Object
    		Dim Temp As String
    		Dim LcaseTemp As String
    		Dim ReadKey As String
    		Dim ReadVariable As String
    		Dim LOKEY As Short
    		Dim HIKEY As Short
    		Dim KEYLEN As Short
    		Dim VAR As Short
    		Dim VARENDOFLINE As Short
    		Dim NF As Short
    		Dim X As Short
    		
    AssignVariables: 
    		NF = FreeFile
    		ReadKey = vbCrLf & "[" & LCase(PutKey) & "]" & Chr(13)
    		KEYLEN = Len(ReadKey)
    		ReadVariable = Chr(10) & LCase(PutVariable) & "="
    		
    EnsureFileExists: 
    		FileOpen(NF, INIpath, OpenMode.Binary)
    		FileClose(NF)
    		SetAttr(INIpath, FileAttribute.Archive)
    		
    LoadFile: 
    		FileOpen(NF, INIpath, OpenMode.Input)
    		Temp = InputString(NF, LOF(NF))
    		Temp = vbCrLf & Temp & "[]"
    		FileClose(NF)
    		LcaseTemp = LCase(Temp)
    		
    LogicMenu: 
    		LOKEY = InStr(LcaseTemp, ReadKey)
    		If LOKEY = 0 Then GoTo AddKey
    		HIKEY = InStr(LOKEY + KEYLEN, LcaseTemp, "[")
    		VAR = InStr(LOKEY, LcaseTemp, ReadVariable)
    		If VAR > HIKEY Or VAR < LOKEY Then GoTo AddVariable
    		GoTo RenewVariable
    		
    AddKey: 
    		Temp = Left(Temp, Len(Temp) - 2)
    		Temp = Temp & vbCrLf & vbCrLf & "[" & PutKey & "]" & vbCrLf & PutVariable & "=" & PutValue
    		GoTo TrimFinalString
    		
    AddVariable: 
    		Temp = Left(Temp, Len(Temp) - 2)
    		Temp = Left(Temp, LOKEY + KEYLEN) & PutVariable & "=" & PutValue & vbCrLf & Mid(Temp, LOKEY + KEYLEN + 1)
    		GoTo TrimFinalString
    		
    RenewVariable: 
    		Temp = Left(Temp, Len(Temp) - 2)
    		VARENDOFLINE = InStr(VAR, Temp, Chr(13))
    		Temp = Left(Temp, VAR) & PutVariable & "=" & PutValue & Mid(Temp, VARENDOFLINE)
    		GoTo TrimFinalString
    		
    TrimFinalString: 
    		Temp = Mid(Temp, 2)
    		Do Until InStr(Temp, vbCrLf & vbCrLf & vbCrLf) = 0
    			Temp = Replace(Temp, vbCrLf & vbCrLf & vbCrLf, vbCrLf & vbCrLf)
    		Loop 
    		
    		Do Until Right(Temp, 1) > Chr(13)
    			Temp = Left(Temp, Len(Temp) - 1)
    		Loop 
    		
    		Do Until Left(Temp, 1) > Chr(13)
    			Temp = Mid(Temp, 2)
    		Loop 
    		
    OutputAmendedINIFile: 
    		FileOpen(NF, INIpath, OpenMode.Output)
    		PrintLine(NF, Temp)
    		FileClose(NF)
        End Function
    To demonstrate its working:

    Create a textbox and a button on the form. Now double click the button to open its click event code. Now add the following code to it:


    Code:
    WriteIniValue("D:\IniTest.ini", "Default", "Text", (TextBox1.Text))
    This will save the text of the Textbox1 into the ini file "D:\IniTest.ini" with the category "Default" and variable "Text".

    Now double click the form or simply goto its load event code. There, add the following line of code:


    Code:
    TextBox1.Text = ReadIniValue("D:\IniTest.ini", "Default", "Text")
    This will read the text from the ini file "D:\IniTest.ini" with the category "Default" and variable "Text" and write it into Textbox1.

    Hope this helps !!
    ty alot!!! u are very helpfull!

Similar Threads

  1. [Solved]Saving info to a text file?
    By HACKINGPIE in forum Call of Duty Modern Warfare 2 GSC Modding Help/Discussion
    Replies: 8
    Last Post: 02-13-2011, 09:38 PM
  2. [Help]Save Text[Solved]
    By Shark23 in forum Visual Basic Programming
    Replies: 7
    Last Post: 04-15-2010, 11:08 AM
  3. [Help] Save Items in Combobox[Solved]
    By FatCat00 in forum Visual Basic Programming
    Replies: 8
    Last Post: 04-13-2010, 04:01 AM
  4. [Help]Saving Settings of a form[solved]
    By poneboy00 in forum Visual Basic Programming
    Replies: 9
    Last Post: 03-20-2010, 09:18 AM
  5. [Help]Save Text to Desktop[Solved]
    By ppl2pass in forum Visual Basic Programming
    Replies: 8
    Last Post: 03-16-2010, 08:45 AM