Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old January 29th, 2004, 02:17 PM
burnoutuk burnoutuk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Nottingham England
Posts: 7 burnoutuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old January 29th, 2004, 03:57 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,751 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 3 h 32 m 46 sec
Reputation Power: 443
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

Reply With Quote
  #3  
Old January 29th, 2004, 04:30 PM
burnoutuk burnoutuk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Nottingham England
Posts: 7 burnoutuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old January 31st, 2004, 10:47 PM
rico rico is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: singapore
Posts: 80 rico User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 48 sec
Reputation Power: 5
Send a message via ICQ to rico
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

Reply With Quote
  #5  
Old January 31st, 2004, 10:50 PM
rico rico is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: singapore
Posts: 80 rico User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 48 sec
Reputation Power: 5
Send a message via ICQ to rico
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

Reply With Quote
  #6  
Old February 1st, 2004, 04:39 AM
burnoutuk burnoutuk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Nottingham England
Posts: 7 burnoutuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by rico
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


Its sorted now, If a textbox is left empty it automaticaly enters either N/A or 0.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Errors


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway