gonzal13
asked on
ComboBox Basics
I am learning on my own VB6 and have some basic questions:
Using a dropdown ComboBox I would like the commands as examples for the following:
Using a menuBox I would like the following in the simplist terms:
Add an item to the box
Remove an item
Clear the list
Print the list
Displaycount
Set alphabetically
Using a dropdown ComboBox I would like the commands as examples for the following:
Using a menuBox I would like the following in the simplist terms:
Add an item to the box
Remove an item
Clear the list
Print the list
Displaycount
Set alphabetically
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here's some good instructions for the above as well: http://www.vtc.com/products/vb6-advan.htm
Offhand (though I've never had a need) - I'd say set up a loop to gather all your combo items for printing...
For x = 0 To Combo1.ListCount - 1
strPrint = strPrint & vbCrLf & Combo1.List(x)
Next x
strPrint = Right(strPrint, Len(strPrint) - Len(vbCrLf))
printer.print strPrint
For x = 0 To Combo1.ListCount - 1
strPrint = strPrint & vbCrLf & Combo1.List(x)
Next x
strPrint = Right(strPrint, Len(strPrint) - Len(vbCrLf))
printer.print strPrint
ASKER
Please Close out this question and refund the points
Gonzal13(Joe)
Gonzal13(Joe)
gonzal13 - are you saying that your questions weren't answered?
I think I've answered most, if not all of them and see no reason why there should be a refund...
I think I've answered most, if not all of them and see no reason why there should be a refund...
ASKER
I did not refer to the notes for this question. On Thursday, I went to see the professor. Thus, I feel that since I did not refer to this site I should geet a rfund of points.
Here is the final code. It a complete working code and more detailed then you provided.
'Maintain a list box.
'Use dropdown combo box
'Use command Buttons
Private Sub cboClear_Click()
'The list is named cboCombo1
'The command clears the Combo1 list
cboCombo1.Clear
End Sub
Private Sub cboCombo1_Change()
End Sub
Private Sub cboCount_Click()
'The ListCount command is used with the message box
'to view the number of lines in the list
MsgBox "The number of Types is " & cboCombo1.ListCount
End Sub
Private Sub cboPrint_Click()
'The ListCount returns the number of items in a list
'If no item is selected, the ListIndex is set to -1.
'The first item in the list is ListIndex 0 and ListCount
'is always one more than the largest List Index
' Index is a database object that provides access to
'Data in rows of a table, based on key values.
Dim intIndex As Integer
Dim intFinalValue As Integer
intFinalValue = cboCombo1.ListCount - 1
For intIndex = 0 To intFinalValue
Printer.Print cboCombo1.List(intIndex)
Next intIndex
Printer.EndDoc
End Sub
'vbExclamation dislays using the Msb Box a
'message found in quotes. Usually a warning Message.
'Private Sub cmdADD_Click()
'
'If cboCombo1.Text <> "" Then
'cboCombo1.AddItem cboCombo1
'Else
'MsgBox "Blank data", vbExclamation, "Error"
'End If
'End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdRemove_Click()
'A combo box control combining the features of a text box
'and list box.
'This control allows the user to select an item either
'by typing into a ComboBox or by selecting it from a list.
'Remove an item from a ListBox or Combo Box.
'object.RemoveItem.Index
'vbInformation Display information using a combo box
If cboCombo1.ListIndex <> -1 Then
cboCombo1.RemoveItem cboCombo1.ListIndex
Else
MsgBox " First select Item to remove", vbInformation, _
"No Selection made"
End If
End Sub
Private Sub cmdSort_Click(Index As Integer)
'Take the combo box list, name the row and sort
cboCombo1.Recordset.sort = "bagles"
End Sub
'Private Sub mnuADD_Click()
'End Sub
'Private Sub mnuFile_Click()
'End Sub
Private Sub Form_Load()
End Sub
Here is the final code. It a complete working code and more detailed then you provided.
'Maintain a list box.
'Use dropdown combo box
'Use command Buttons
Private Sub cboClear_Click()
'The list is named cboCombo1
'The command clears the Combo1 list
cboCombo1.Clear
End Sub
Private Sub cboCombo1_Change()
End Sub
Private Sub cboCount_Click()
'The ListCount command is used with the message box
'to view the number of lines in the list
MsgBox "The number of Types is " & cboCombo1.ListCount
End Sub
Private Sub cboPrint_Click()
'The ListCount returns the number of items in a list
'If no item is selected, the ListIndex is set to -1.
'The first item in the list is ListIndex 0 and ListCount
'is always one more than the largest List Index
' Index is a database object that provides access to
'Data in rows of a table, based on key values.
Dim intIndex As Integer
Dim intFinalValue As Integer
intFinalValue = cboCombo1.ListCount - 1
For intIndex = 0 To intFinalValue
Printer.Print cboCombo1.List(intIndex)
Next intIndex
Printer.EndDoc
End Sub
'vbExclamation dislays using the Msb Box a
'message found in quotes. Usually a warning Message.
'Private Sub cmdADD_Click()
'
'If cboCombo1.Text <> "" Then
'cboCombo1.AddItem cboCombo1
'Else
'MsgBox "Blank data", vbExclamation, "Error"
'End If
'End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdRemove_Click()
'A combo box control combining the features of a text box
'and list box.
'This control allows the user to select an item either
'by typing into a ComboBox or by selecting it from a list.
'Remove an item from a ListBox or Combo Box.
'object.RemoveItem.Index
'vbInformation Display information using a combo box
If cboCombo1.ListIndex <> -1 Then
cboCombo1.RemoveItem cboCombo1.ListIndex
Else
MsgBox " First select Item to remove", vbInformation, _
"No Selection made"
End If
End Sub
Private Sub cmdSort_Click(Index As Integer)
'Take the combo box list, name the row and sort
cboCombo1.Recordset.sort = "bagles"
End Sub
'Private Sub mnuADD_Click()
'End Sub
'Private Sub mnuFile_Click()
'End Sub
Private Sub Form_Load()
End Sub