[RESOLVED] drop down list
hii.. hw can i build a form with two drop down lists( combo boxes type 0), one for students and the other for their study center code. when this form is loaded fill the lists from the arrays. if the user pulls down one of the list and clicks on a student the corresponding study center code is displayed in the text box of the other list?
thnx for rplyin..:)
1 Attachment(s)
Re: [RESOLVED] drop down list
here is what u r lookin for man
download it from the attachment and code goes here too.
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const CB_SHOWDROPDOWN = &H14F
'Written by Gaurav_Raj420
Private Sub Command1_Click()
On Error GoTo handler
Dim sStr As String
Dim Stud As Integer
Dim ComItm() As String
Dim Lup As Integer
Stud = InputBox("How Much Students ?", "Students")
ReDim ComItm(Stud)
For Lup = LBound(ComItm) To UBound(ComItm)
sStr = InputBox("Enter " & Lup & " Name")
Combo1.AddItem sStr
Next
MsgBox "Students Entries Have Been Added " & vbCrLf & "See them now", vbExclamation, "Students Entries"
SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 1, 1
Exit Sub
handler:
MsgBox Err.Description & vbNewLine & Err.Number, vbCritical, "Error"
End Sub
Private Sub Command2_Click()
On Error GoTo handler
Dim sStr As String
Dim StudyCntr As Integer
Dim ComItm() As String
Dim Lup As Integer
StudyCntr = InputBox("How Much Study Centers ?", "Study Center")
ReDim ComItm(StudyCntr)
For Lup = LBound(ComItm) To UBound(ComItm)
sStr = InputBox("Enter " & Lup & " Name")
Combo2.AddItem sStr
Next
MsgBox "Study Center's Entries Have Been Added " & vbCrLf & "See them now", vbExclamation, "Study Center Entries"
SendMessage Combo2.hwnd, CB_SHOWDROPDOWN, 1, 1
Exit Sub
handler:
MsgBox Err.Description & vbNewLine & Err.Number, vbCritical, "Error"
End Sub
Private Sub Command3_Click()
On Error GoTo handler
Dim Srch As Integer
Srch = InputBox("Enter Value To Search", "Search")
MsgBox "Name = " & Combo1.List(Srch) & " Education Center = " & Combo2.List(Srch)
Exit Sub
handler:
MsgBox Err.Description & vbNewLine & Err.Number, vbCritical, "Error"
End Sub
Private Sub Form_Load()
Combo1.Text = ""
Combo2.Text = ""
Label1.Caption = "Students"
Label2.Caption = "Study Centers"
Command1.Caption = "E&nter Students Name"
Command2.Caption = "&Enter Study Center"
Command3.Caption = "&Search"
Command1.Width = 2100
Command2.Width = 2100
Me.Width = 7000
End Sub
i know the topic is already [resolved] but i want to make this post because i made this prog for u adad.. :wave:
Re: [RESOLVED] drop down list
ram ram bhai.. thnx bro..