Jblake00 Posted October 2, 2003 Posted October 2, 2003 Alright I learned how to create a message box. So that puts me a step a head of my lesson. I wasn't supposed to know how to do that yet!! My instructor is supposed to be infoming us, hopefully tonight about some IF and then situtions. Maybe from that I will learn how to take care of my program problems. But if yall have any tips or info I would appreciate it. MsgBox("Warning if your debt is not payed promptly, Then it will be turned over to the StrongArmCollectionAgency.", , "Consolation") But here is my two troubles. [*]If there is no input in my text boxes the program pops up an error dialog. [*] I only want the message box to popup if the amount of the fine = 25 dollars or more. [/list=1] Here is my code. Private Sub BtnCalulateFines_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalulateFines.Click 'Clayton I am have much problems with this code. 'When I use this code it works fine as long as there is an input. 'But when there is no input it brings up an exception form when I debug. 'So I tryed this try It keeps the program from crashing but also, 'gives no output when there is an input REM Try Dim sum As Double sum = CDbl(TxtListNumBooks.Text) * 0.1 * CDbl(TxtListNumDaysLate.Text) REM Catch ex As Exception REM Dim sum As DialogResult REM sum = 0.0 LblShowFines.Text = "Your total fine is: " & CStr(FormatCurrency(sum)) LblShowFines.BorderStyle = BorderStyle.FixedSingle MsgBox("Warning if your debt is not payed promptly, Then it will be turned over to the StrongArmCollectionAgency.", , "Consolation") REM End Try End Sub Quote Looking to expand my VB.Net knowledge. Jblake00
Jblake00 Posted October 3, 2003 Author Posted October 3, 2003 The problem is solved. Here is the solution. Private Sub BtnCalulateFines_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalulateFines.Click REM this button is used to do all the calculations Dim sum As Double If TxtListNumBooks.Text = "" Then TxtListNumBooks.Text = "0" End If If TxtListNumDaysLate.Text = "" Then TxtListNumDaysLate.Text = "0" End If sum = CDbl(TxtListNumBooks.Text) * 0.1 * CDbl(TxtListNumDaysLate.Text) LblShowFines.Text = "Your total fine is: " & CStr(FormatCurrency(sum)) LblShowFines.BorderStyle = BorderStyle.FixedSingle 'This is the code used to make a popup message appear when the fine is more than $1.50 If (sum > "1.5") Then MsgBox("Warning if your debt is not payed promptly, Then it will be turned over to the StrongArmCollectionAgency.", , "Consolation") End If If (sum < "1.49") Then LlbThankYou.Text = "Thanks for your prompt payment" End If End Sub Quote Looking to expand my VB.Net knowledge. Jblake00
Administrators PlausiblyDamp Posted October 3, 2003 Administrators Posted October 3, 2003 You should really be using MessageBox.Show under .Net rather than MsgBox - also CStr, CDbl are VB6 functions rather than .Net code. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jblake00 Posted October 4, 2003 Author Posted October 4, 2003 I am only doing things the way the book shows. The book is An introduction to programing with VB.Net. As far as the code it workes fine regardless of the version. The book used all the code I used for examples. However I don't feel like the book was the best choice that could have been made for the course, I have always felt that for programs that are made for microsoft a book by microsoft should be used to accompany it. And yes microsoft does have a book called An introduction to programming using : Visual Basics.Net... The book we have has several errors that I know of. Such as LstBox1 looks like 1stBox1... The editor strongly reccomends naming buttons names like BtnSomething but when he shows code sniplets he names his own btnsomething. That is just things that a beginer like me knows about! Thank god for Books- A- Million. Quote Looking to expand my VB.Net knowledge. Jblake00
Administrators PlausiblyDamp Posted October 6, 2003 Administrators Posted October 6, 2003 Depends on what you are converting ;) e.g. sum = CDbl(TxtListNumBooks.Text) * 0.1 * CDbl(TxtListNumDaysLate.Text) would be better written as sum = Double.Parse(TxtListNumBooks.Text) * 0.1 * Double.Parse(TxtListNumDaysLate.Text) while CStr can usually be replaced with the .ToString method. also DirectCast can often be used as a more type-safe version of CType. Also try and avoid advertising Warez Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jblake00 Posted October 9, 2003 Author Posted October 9, 2003 Where did the advertising thing comein at ??? Seems like your doing the advertising by mentioning the name!!! Quote Looking to expand my VB.Net knowledge. Jblake00
Administrators PlausiblyDamp Posted October 9, 2003 Administrators Posted October 9, 2003 There was a post that has since been deleted that was advertising them. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jblake00 Posted October 15, 2003 Author Posted October 15, 2003 Well I don't believe I mentouned them but as you can see I make menty typos, so I could have tuped wharis and been misunderstood. Also for anybody that wants ot know the University I attend is furnished a copy of many Microsoft programs for students to use as long as they are willing to sign a form. Quote Looking to expand my VB.Net knowledge. Jblake00
Administrators PlausiblyDamp Posted October 15, 2003 Administrators Posted October 15, 2003 The post in question wasn't made by you. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jblake00 Posted October 22, 2003 Author Posted October 22, 2003 problem solved Quote Looking to expand my VB.Net knowledge. Jblake00
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.