?
Solved

Validation and Combo box question

Posted on 2003-02-19
5
Medium Priority
?
213 Views
Last Modified: 2010-05-01
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
Comment
Question by:marks97
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 2

Expert Comment

by:Jacamar
ID: 7984308
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
 
LVL 2

Expert Comment

by:Jacamar
ID: 7984323
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
 
LVL 2

Expert Comment

by:Jacamar
ID: 7984473
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
 
LVL 2

Accepted Solution

by:
Jacamar earned 200 total points
ID: 7987335
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
 

Author Comment

by:marks97
ID: 7993233
Thanks for your help.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question