Advertisement
6_2008-2009 Files/ File Controls/ Input/ Output #212448

Read / Write Combo Boxs

This code will let you read in values from a file of your choice, probably a .ini or .txt into a combobox. It will also let you save the contents of the combobox to a file of your choice. Example: Call WriteCombo(combo1, "C:/example.ini") or Call ReadCombo(combo1, "C:/example.ini")

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
Public Sub ReadCombo(combobox As combobox, Filename As String)
  On Error GoTo Err
  Open Filename For Input As #1
 

  Do While Not EOF(1)
    Input #1, lstinput
    combobox.AddItem lstinput
  Loop
  Close #1
  Exit Sub
Err:
  MsgBox "Error In ReadCombo" & Chr(13) & Chr(13) & Err.Number _
  & " - " & Err.Description, vbCritical, "Error"
  Exit Sub
End Sub

Public Sub WriteCombo(combobox As combobox, Filename As String)

  If combobox.ListCount <= 0 Then
    MsgBox "Combobox is empty - cannot write To file!", vbCritical, "Error"
    End
  End If
  On Error GoTo Err
  Open Filename For Output As #1
  For i = 0 To combobox.ListCount - 1
    Print #1, combobox.List(i)
  Next
  Close #1
  Exit Sub
Err:
  MsgBox "Error In WriteCombo" & Chr(13) & Chr(13) & Err.Number _
  & " - " & Err.Description, vbCritical, "Error"
  Exit Sub
End Sub
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine