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: 215
  • Last Modified:

Validation and Combo box question

Hi. Im just starting to use Visual Basic for a school project so my skills are limited to say the least. The VB I am using is only the version in Excel so it is not very powerful. It has taken me a good few days to get to where I am but now I am stuck so was wondering if any of you guys could help me. I have 3 questions. The first is:

Is there a way to force people to only be able to enter letters and all symbols such as [?!"#$%^&*()>.] but no numbers into a textbox in excel VBA.

The second is:

Is there a way to use a combo box in a UserForm that by the selection you make, determines which UserForm you go to. e.g. if i select 1 from the combo box, it takes me to UserForm 1 or if I select 2 from the combo box it takes me to UserForm2.

The third is:

Is there a way to get TextBoxes that are linked to a cell in Excel to reveal what the cell value is in the TextBox without having to put the cursor in the TextBox first. The Code I use currently to link to the cells is:
TextBox1.Text = Range("cell").Value

These are probably very basic questions but i cant find a way to do them and have searched lots of forums looking for the answer. Any help you can provide will be greatly appreciated.
Mark Thurley
0
marks97
Asked:
marks97
  • 4
1 Solution
 
JacamarCommented:
first question

if isNumeric (text1.text) then
call msgbox("You can not enter nubers",vbinformation)
end if

Probably do this in the text_change event
0
 
JacamarCommented:
Second Question

Private sub Combo1_Click
if Combo = 1 then
Form1.visible = true
Form.visible = false
end if

if Combo=2 then
Form2.visible = true
Form.visible = false
end if

end sub
0
 
JacamarCommented:
Don't look at question 2.  It is wrong.  I will tell you tomorrow morning how to do it if it hasn't been answered by then.
0
 
JacamarCommented:
Second Question.

'   Set array for Items in Combo box
'   This is done above procedures
Private Enum Items
    Item = 0
    Item2 = 1
    Item3 = 2
    Item4 = 3
End Enum

Private fItem As Items



Private sub Form_Load()

Call Combo.Clear
Call Combo.AddItem("Item1")
Call Combo.AddItem("Item2")
Call Combo.AddItem("Item3")
Call Combo.AddItem("Item4")
Combo.ListIndex = fItem

end sub

Private sub Command1_click()
dim sgItem1 as single    

if fItem = Item1 then
 sgItem1 = 1
 do whatever else you want in this situation
end if

' do the same for other items in the combobox

end sub


This will work.
0
 
marks97Author Commented:
Thanks for your help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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