Stopping and Saving problem

Discussion in 'Code Snippets and Tutorials' started by the_skip, Mar 4, 2007.

  1. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    I have a code in my program that is supposed to stop the program when I click a button to maje bolstop = true and here it is
    Code (Text):
    1. If bolstop = True Then
    2. lstResults.AddItem " " & Time & ": Program Stopped"
    3. cmduserAbStart.Enabled = True
    4. Exit Sub
    5. End If
    What is wrong with this I have to click the stopping button 10 times to stop it here is the stoping button code
    Code (Text):
    1. Private Sub Command5_Click()
    2. bolstop = True
    3. cmduserAbStart.Enabled = True
    4. lstResults.AddItem "Ending Program Please Wait"
    5. End Sub
    this is ticking me off
    And also can someone link me to a list box saving tutorial
     
  2. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    The code to stop the program should work, but you will have to put it in more than only one position (if you're not makeing a for...next contruct)...

    And what do you mean to "save" listboxes??? As a file or as a registry key???
     
  3. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    ok thanks I mean have a list box be saved as a texet file.
    I put that in multiple places but it still dosn't work
     
  4. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    ok, so here is the code to save a ListBox as a Text file:

    1. Create a common dialogue and name it "CD";
    2. The ListBox here is called List1 and the button Command1
    3. Paste this code:
    Code (Text):
    1. Private Sub Command1_Click()
    2.     On Error Resume Next
    3.     Dim lngTemp As Long
    4.     CD.DialogTitle = "Save Listbox"
    5.     CD.InitDir = App.Path
    6.     CD.Flags = &H4
    7.     CD.Filter = "Text Files (*.txt)|*.txt"
    8.     CD.ShowSave
    9.     If CD.Filename = "" Then Exit Sub
    10.     Open CD.Filename For Output As #1
    11.     For lngTemp = 0 To List1.ListCount - 1
    12.         Print #1, List1.List(lngTemp)
    13.     Next lngTemp
    14.     Close #1
    15. End Sub
    Done!!! :D
     
  5. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    is there anyway I could have that stoping code better and where should I put the timer code and do I need a vb6 timer to use it