Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 18th, 2007, 04:43 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Decimal point

Hi there

i have a problem with my little calculator project, i did everything but i got stuck at the decimal place, What i want the calculator to do is to give out an error when a user try to put in morethan one decimal point eg. 12.30.30 or 12..30.

can somebody help me please.

regards

Marcus

here is my code

Private Sub btnOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOne.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

Else

tbcalculate.Text = tbcalculate.Text & btnOne.Text

tbChange.Clear()

End If

End Sub

Private Sub btnTwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTwo.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

Else

tbcalculate.Text = tbcalculate.Text & btnTwo.Text

tbChange.Clear()

End If

End Sub

Private Sub btnThree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThree.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

Else

tbcalculate.Text = tbcalculate.Text & btnThree.Text

tbChange.Clear()

End If

End Sub

Private Sub btnFour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFour.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

Else

tbcalculate.Text = tbcalculate.Text & btnFour.Text

tbChange.Clear()

End If

End Sub

Private Sub btnFive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFive.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

Else

tbcalculate.Text = tbcalculate.Text & btnFive.Text

tbChange.Clear()

End If

End Sub

Private Sub btnSix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSix.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

Else

tbcalculate.Text = tbcalculate.Text & btnSix.Text

tbChange.Clear()

End If

End Sub

Private Sub btnSeven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSeven.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

Else

tbcalculate.Text = tbcalculate.Text & btnSeven.Text

tbChange.Clear()

End If

End Sub

Private Sub btnEight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEight.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

Else

tbcalculate.Text = tbcalculate.Text & btnEight.Text

tbChange.Clear()

End If

End Sub

Private Sub btnNine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNine.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

Else

tbcalculate.Text = tbcalculate.Text & btnNine.Text

tbChange.Clear()

End If

End Sub

Private Sub btnZero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZero.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

ElseIf tbcalculate.Text = Nothing Then

MsgBox("Must not have Zero dollards to change")

Else

tbcalculate.Text = tbcalculate.Text & btnZero.Text

End If

End Sub

Private Sub btnDecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecimal.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

ElseIf tbcalculate.Text = Nothing Then

MsgBox("Must not have less than total amount")

Else

tbcalculate.Text = tbcalculate.Text & btnDecimal.Text

End If

DecimalFlag = True

End Sub

Private Sub btnChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChange.Click

If tbCal.Text = Nothing Then

MsgBox("Must have a TOTAL to calculate change")

ElseIf tbcalculate.Text = Nothing Then

MsgBox("Must have a Cash Amount to calculate change")

ElseIf total1 > tbcalculate.Text Then

MsgBox("Total can not be greater than Cash amount")

Else

cal1 = tbcalculate.Text - total1

tbChange.Text = FormatCurrency(cal1)

End If

tbcalculate.Text = 0

tbcalculate.Clear()

End Sub

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

tbChange.Clear()

tbcalculate.Text = 0

tbcalculate.Clear()

End Sub


Reply With Quote
  #2 (permalink)  
Old January 18th, 2007, 05:25 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use the IsNumeric function to test if the texbox is numeric.

If Isnumeric(textbox.text) then

Or you can write your own sub to test more in detail.

Reply With Quote
  #3 (permalink)  
Old January 18th, 2007, 05:37 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanks alot for your reply, however its still allow me to have 2 decimal points (1..1) but wen i put in the third decimal point then its show the error message.

Im really bad at this so please help me out.

Regards

Marcus

Reply With Quote
  #4 (permalink)  
Old January 18th, 2007, 05:55 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much i have figured it out.

Regards

Marcus

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any point RobReid Flash (all versions) 0 September 26th, 2008 09:07 AM
Replace decimal point with another value bonekrusher XSLT 8 March 5th, 2007 12:22 PM
decimal data type all 0's after decimal gobotsoup SQL Server ASP 1 February 28th, 2007 02:32 PM
How to control the decimal point precision johnsonlim026 ASP.NET 1.0 and 1.1 Basics 0 August 7th, 2005 11:58 PM
Decimal Point interrupt Javascript How-To 4 March 16th, 2005 05:53 AM



All times are GMT -4. The time now is 05:39 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.