Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Looking to expand my VB.Net knowledge.

 

Jblake00

Posted

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    

Looking to expand my VB.Net knowledge.

 

Jblake00

Posted

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.

Looking to expand my VB.Net knowledge.

 

Jblake00

  • Administrators
Posted

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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Where did the advertising thing comein at ???

Seems like your doing the advertising by mentioning the name!!!

Looking to expand my VB.Net knowledge.

 

Jblake00

Posted
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.

Looking to expand my VB.Net knowledge.

 

Jblake00

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...