Results 1 to 5 of 5

Thread: help me in open code

  1. #1

    Thread Starter
    Lively Member milen's Avatar
    Join Date
    May 2006
    Posts
    116

    Exclamation help me in open code

    this is the save code

    VB Code:
    1. Private Sub Command1_Click()
    2. CommonDialog1.ShowSave
    3. Dim frm As Form
    4.     Dim ctl As Control
    5.     Open (CommonDialog1.FileName) For Output As #1
    6.     For Each frm In Forms
    7.         For Each ctl In frm.Controls
    8.             If TypeOf ctl Is TextBox Or TypeOf ctl Is Label Then
    9.            
    10.                    Print #1, frm.Name & " : " & ctl.Name & " : " & ctl
    11. End If
    12.         Next
    13.     Next
    14.     Close #1
    15. End Sub
    16. -------------------
    17. my probleme is in the open code of this save code
    18. this is the code
    19. Private Sub Command2_Click()
    20. CommonDialog1.ShowOpen
    21. Dim colForms As Collection
    22.     Dim sParts() As String, sTemp As String, N As Long
    23.    
    24.     Set colForms = New Collection
    25.     For N = 0 To Forms.Count - 1
    26.         colForms.Add Forms(N), Forms(N).Name
    27.     Next N
    28.    
    29.     Open (CommonDialog1.FileName) For Input As #1
    30.         Do Until EOF(1)
    31.             Line Input #1, sTemp
    32.             sParts = Split(sTemp, " : ")
    33.             colForms(sParts(0)).Controls(sParts(1)) = sParts(2)
    34.         Loop
    35.     Close #1
    36.     Set colForms = Nothing
    37.     End Sub
    -------------------
    when i click in f5 button in microsoft visual basic look to this error


    colForms(sParts(0)).Controls(sParts(1)) = sParts(2)
    help me please
    Last edited by RobDog888; Jul 22nd, 2006 at 10:56 PM. Reason: Added [vbcode] tags

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: help me in open code

    What is the error you are getting?

    Also could you please use the [Highlight=VB]Your code here[/vbcode] tags

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: help me in open code

    try changing this bit:
    VB Code:
    1. Line Input #1, sTemp
    2.     If Len(sTemp) Then
    3.         sParts = Split(sTemp, " : ")
    4.         colForms(sParts(0)).Controls(sParts(1)) = sParts(2)
    5.     End If

  4. #4

    Thread Starter
    Lively Member milen's Avatar
    Join Date
    May 2006
    Posts
    116

    Exclamation Re: help me in open code

    Hii guys
    This code dosnt work do you have any way or another code to get
    the open code of it
    please answer soon
    regard's
    milen

  5. #5
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: help me in open code

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim Frm As Form
    3. Dim ctl As Control
    4.  
    5.     CommonDialog1.ShowSave
    6.     Open (CommonDialog1.FileName) For Output As #1
    7.         For Each Frm In Forms
    8.             For Each ctl In Frm.Controls
    9.                 If TypeOf ctl Is TextBox Or TypeOf ctl Is Label Then
    10.                     Print #1, Frm.Name & " : " & ctl.Name & " : " & ctl
    11.                 End If
    12.             Next
    13.         Next
    14.     Close #1
    15. End Sub
    16.  
    17. Private Sub Command2_Click()
    18. CommonDialog1.ShowOpen
    19. Dim sParts() As String, sTemp As String, N As Long
    20.  
    21. Open (CommonDialog1.FileName) For Input As #1
    22.     Do Until EOF(1)
    23.         Line Input #1, sTemp
    24.         sParts = Split(sTemp, " : ")
    25.         GetForm(sParts(0)).Controls(sParts(1)) = sParts(2)
    26.     Loop
    27. Close #1
    28.  
    29. End Sub
    30.  
    31. Function GetForm(FormName As String) As Form
    32. Dim Frm As Form
    33.     For Each Frm In Forms
    34.         If Frm.Name = FormName Then
    35.             Set GetForm = Frm
    36.             Exit Function
    37.         End If
    38.     Next
    39. End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width