|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Errors
Hi just wondering if someone could tell me how i do this.
I want to display a Message Box with an error if when a command button is clicked and a text box has not had any data entered into it. so for each text box i need a message box which says where teh error is. Heres the code: Private Sub cmdCalc_Click() Dim Cons As Currency Dim floor As Integer Dim Colour As Integer Dim Glass As Integer Dim Hardware As Currency Dim hardwood As Integer Dim area As Integer txtMaterials.Text = Format(aorder.Materials, "Currency") txtMaterialsVat.Text = Format(aorder.Installation, "Currency") txtLabour.Text = Format(aorder.Labour, "Currency") txtTotalCost.Text = Format(aorder.Total, "Currency") Cons = txtConsCost.Text floor = txtFloorCost.Text Colour = txtColourCost.Text Glass = txtGlassCost.Text Hardware = txtHardwareCost.Text hardwood = txtHardwoodCost.Text area = txtAreaCost.Text aorder.Materials = Cons / 100 * floor + Cons / 100 * Colour + Cons / 100 * Glass + Cons / 100 * hardwood + Cons / 100 * area + Hardware + Cons aorder.Installation = aorder.Materials / 100 * 17.5 + aorder.Materials aorder.Labour = aorder.Materials / 100 * 55 aorder.Total = aorder.Installation + aorder.Labour End Sub I thought it'd be something like: If Cons = "" Then MsgBox "Error in Cons" Elseif area= "" Then MsgBox "Error in Area" and so on but i cant get that working. Thank you for any help ![]() Edit: Also if txtColourCost.Text is left empty i want to calculate everything else and leave that out. So is it Elseif isEmpty(txtColourCost.Text ) Then *the calculation without the txtcolourcost.text* But that doesnt work either. Last edited by burnoutuk : January 29th, 2004 at 02:28 PM. |
|
#2
|
||||
|
||||
|
You could do something like this
Code:
Private Sub cmdSubmit_Click()
If (txtName.Text = "") Then
Call AlertUser("Name", "Name field is required")
End If
End Sub
Public Sub AlertUser(FieldName As String, ErrMsg As String)
Dim response As Integer
response = MsgBox(ErrMsg, vbOKOnly, "Error in " & FieldName)
End Sub
|
|
#3
|
|||
|
|||
|
Thats worked
But... now if i dont select data for one of the text boxes when i click Calculate i get an error saying "type missmatch" and goes to: Cons = txtConsCost.Text floor = txtFloorCost.Text Colour = txtColourCost.Text Glass = txtGlassCost.Text Hardware = txtHardwareCost.Text hardwood = txtHardwoodCost.Text area = txtAreaCost.Text Thank you for the last bit though. |
|
#4
|
|||
|
|||
|
hmm.. why dun u try to declare those 2 currency as integer and try see whether do u have that error again? like Cons as Integer
|
|
#5
|
|||
|
|||
|
hmm.. why dun u try to declare those currency as integer and try see whether do u have that error again? like Cons as Integer
|
|
#6
|
|||
|
|||
|
Quote:
Its sorted now, If a textbox is left empty it automaticaly enters either N/A or 0. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Errors |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|