![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 10
|
I'm not sure if this is possible but I'll ask anyhoo.
I have this code: --- Private Sub CalcButton_Click() If CostBox.Value = "?" Then MsgBox ("Invalid Cost") CostBox.Value = "" Else If CostBox.Value = "?" Then a = CostBox.Value b = QuantityBox.Value answer = a * b SubCostBox.Text = answer End If End If End Sub --- The question marks are the problem. I need CostBox.Value to be any number but NOT a letter. Are there any wildcards I could use, one for letters and one for numbers? Any help or put-downs at my gross incompetence would be much appreciated! stiffrimpet |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Posts: 363
|
Try using the val function
if val(CostBox.Value) = 0 then msgbox "you must enter numbers only CostBox.Value = 0 endif
__________________
It's never too late to learn something new. Ricky |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi
Another function as well... If Not IsNumeric(CostBox.Text) Then Msgbox "You must enter numbers only." CostBox.Text = "" CostBox.SetFocus End If Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|