What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Help with Visual Basic code

Help with Visual Basic code
Author: Message:
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
32 / Male / Flag
Joined: Mar 2003
RE: Help with Visual Basic code
Bah...
Then try replacing the LoadFormState sub with:

code:
Public Sub LoadFormState(ByVal SourceForm As Form)

Dim A        As Long     ' general purpose

    'Dim B As Long
Dim C        As Long
Dim TXT      As String   ' general purpose
Dim fData    As String   ' used to hold File Data
    ' these are variables used for controls data
Dim cType    As String   ' Type of control
Dim cName    As String   ' Name of control
Dim cNum     As Integer  ' number of control
    ' vars for the file
Dim FileName As String   ' where to save to
Dim FHandle  As Long     ' FileHandle
    ' error handling code
    'On Error GoTo fError
    ' we create a filename based on the formname
    FileName = App.Path & "\" & SourceForm.Name & ".set"
    ' abort if file does not exist
    If LenB(Dir(FileName)) = 0 Then
#If DebugMode = 1 Then
        Debug.Print "File Not found:" & FileName
#End If
        Exit Sub
    End If
    ' Get a filehandle
    FHandle = FreeFile()
    ' open the file
#If DebugMode = 1 Then
    Debug.Print "------------------------------------------------------>"
    Debug.Print "Loading FormState:" & SourceForm.Name
    Debug.Print "FileName:" & FileName
#End If
    Open FileName For Input As FHandle
    ' go through file
    Do While Not EOF(FHandle)
        Line Input #FHandle, cType
        Line Input #FHandle, cName
        ' Get control number
        cNum = -1
        For A = 0 To SourceForm.Controls.Count - 1
            If SourceForm.Controls(A).Name = cName Then
                cNum = A
            End If
        Next A
        ' add some debug info if in debugmode
#If DebugMode = 1 Then
        Debug.Print "Control Type=" & cType
        Debug.Print "Control Name=" & cName
        Debug.Print "Control Number=" & CStr(cNum)
#End If
        ' if we find control
        If Not cNum = -1 Then
            ' Depending on type of control, what data we get
            Select Case cType
            Case "TextBox"
                Line Input #FHandle, fData
                fData = ""
                TXT = ""
                Line Input #FHandle, fData
                Debug.Print fData
                SourceForm.Controls(cNum).BackColor =CLng(fData)
                fData = ""
                BackColor = ""
               
               
                Do While Not fData = "EndText"
                    If Not LenB(TXT) = 0 Then
                        TXT = TXT + vbNewLine
                    End If
                    TXT = TXT + fData
                    Line Input #FHandle, fData
                Loop
                ' update control
                SourceForm.Controls(cNum).Text = TXT
            Case "CheckBox"
                ' we get the value
                Line Input #FHandle, fData
                ' update control
                SourceForm.Controls(cNum).Value = fData
            Case "OptionButton"
                ' we get the value
                Line Input #FHandle, fData
                ' update control
                SourceForm.Controls(cNum).Value = fData
            Case "ListBox"
                ' clear listbox
                SourceForm.Controls(cNum).Clear
                ' get .text property
                Line Input #FHandle, fData
                SourceForm.Controls(cNum).Text = fData
                ' read past /startlist
                Line Input #FHandle, fData
                fData = ""
                TXT = ""
                ' Get List
                Do While Not fData = "EndList"
                    If Not LenB(fData) = 0 Then
                        SourceForm.Controls(cNum).AddItem fData
                    End If
                    Line Input #FHandle, fData
                Loop
                ' get listindex
                Line Input #FHandle, fData
                SourceForm.Controls(cNum).ListIndex = Val(fData)
            Case "ComboBox"
                ' Clear combobox
                SourceForm.Controls(cNum).Clear
                ' Get Text
                Line Input #FHandle, fData
                SourceForm.Controls(cNum).Text = fData
                ' readpast /startlist
                Line Input #FHandle, fData
                fData = ""
                TXT = ""
                ' get list
                Do While Not fData = "EndList"
                    If Not LenB(fData) = 0 Then
                        SourceForm.Controls(cNum).AddItem fData
                    End If
                    Line Input #FHandle, fData
                Loop
            End Select ' what type of control
        End If ' if we found control
        ' read till seperator
        fData = ""
        Do While Not fData = "|<->|"
            Line Input #FHandle, fData
        Loop
    Loop ' not end of File (EOF)
    ' close file
#If DebugMode = 1 Then
    Debug.Print "Closing file.."
    Debug.Print "<------------------------------------------------------"
#End If
    Close #FHandle

Exit Sub


End Sub
YouTube closed-captions ripper (also allows you to download videos!)
01-24-2005 11:52 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Help with Visual Basic code - by DJeX on 01-19-2005 at 11:06 PM
RE: Help with Visual Basic code - by Dempsey on 01-21-2005 at 11:32 PM
RE: Help with Visual Basic code - by DJeX on 01-23-2005 at 04:55 AM
RE: Help with Visual Basic code - by Mike on 01-23-2005 at 07:24 AM
RE: Help with Visual Basic code - by DJeX on 01-23-2005 at 08:50 PM
RE: Help with Visual Basic code - by Mike on 01-23-2005 at 08:54 PM
RE: Help with Visual Basic code - by DJeX on 01-23-2005 at 09:00 PM
RE: Help with Visual Basic code - by Mike on 01-23-2005 at 09:03 PM
RE: Help with Visual Basic code - by DJeX on 01-23-2005 at 10:58 PM
RE: Help with Visual Basic code - by Mike on 01-24-2005 at 11:52 AM
RE: Help with Visual Basic code - by DJeX on 01-24-2005 at 08:30 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On