Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

ComboBox Help !

let's say i have a Combobox which contain a list (January , February ... December) .So what i want to do is , when u insert a value between 1 to 12 into a textbox , it'll automatically correspond to the comboBox listindex and selected the actual Month .


for exmaple , text1 = 3 , then the combobox will automatically shift to March .

thanks

0
vb_newbie
Asked:
vb_newbie
  • 3
1 Solution
 
vb_newbieAuthor Commented:
issit impossible to do that ?
0
 
vb_newbieAuthor Commented:
issit impossible to do that ?
0
 
GPrentice00Commented:
Option Explicit
' Form with combo1 and Text1 controls.
' Combo1 populated with Jan,Feb, etc... (12 entries)
' Index of Jan=0, Index of Feb=1...

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
   ' detect the enter key press
   If KeyCode = vbKeyReturn Then
      PopCombo
   End If
End Sub

Private Sub Text1_Validate(Cancel As Boolean)
   ' Validation fires when focus is being shifted to a different control
   PopCombo
End Sub
   
Private Sub PopCombo()
' Call this procedure at any time you want the text value examined
' and transferred into a combo box display...

   Dim vText As Single
   If Not IsNumeric(Text1) Then
      MsgBox "Not an integer 1-12"
      Text1 = ""
   Else 'is a numeric entry
      vText = Val(Text1)
      If vText > 0 And vText < 13 Then
         Combo1 = Combo1.List(vText - 1)
      Else
         MsgBox "Must be positive integer within range 1-12"
         Text1 = ""
      End If
   End If


End Sub
0
 
vb_newbieAuthor Commented:
issit impossible to do that ?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now