Results 1 to 2 of 2

Thread: Combo box & Saving

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    1

    Question

    Ok,
    I'm having problems with my final project.
    First,
    How can I limit the values in a combo box????
    Example: I have a combo box with values 2,3,4.
    When the user goes to that combo box to chose one and enters any other data, it accepts it. I don't want that!!
    HELP!!!

    Second,
    What do I do to save a record in a file? The file is created but will start off wit no records. Do I Open for Output, and then what? It's not working.......


  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Option Explicit
    
    Private Sub Combo1_KeyPress(KeyAscii As Integer)
    'keep text from being entered in combo1
        KeyAscii = 0
    End Sub
    
    Private Sub Command1_Click()
    'load combo with items
        Dim i As Integer
        For i = 1 To 4
          Combo1.AddItem i
        Next i
        
        Dim myFile As String
        Dim intNum As Integer
        
        myFile = "C:\my documents\myfile.txt"
        intNum = FreeFile
    'if you use output you overwrite, append adds to the bottom
    'of existing file, and input reads
    
        Open myFile For Output As intNum
    'save the contents of the combobox to a file
          For i = 0 To Combo1.ListCount - 1
            Combo1.ListIndex = i
            Print #intNum, Combo1.Text
          Next i
          Close #intNum
          Combo1.ListIndex = 0
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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