It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Im new with Visual Basic NEED HELP pls

Moderator: dafunkymunky

Im new with Visual Basic NEED HELP pls

Postby SemChance on Sun Feb 17, 2008 4:30 am

Everytime I multiply "daysInteger" with something else I get 0, and i Also have problems trying to display my Error message. I cant get them to work, please tell me what am i doing wrong!!
thnx


Public Class carRentalForm

' Dimension module - level variables and constants.
Private totalChargeDecimal, milesPriceDecimal, daysPriceDecimal As Decimal
Private milesInteger, zipCodeInteger, daysInteger As Integer
Const MILES_PRICE_Decimal As Decimal = 0.12D
Const DAYS_PRICE_Decimal As Decimal = 15D

Private Sub calculateButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles calculateButton.Click
' Calculate the miles and total charge.
Dim beginningInteger, endingInteger As Integer

With Me
Try
' Convert quantity to numeric variable.
beginningInteger = Integer.Parse(.beginningTextBox.Text)
endingInteger = Integer.Parse(.endingTextBox.Text)

Try

'Calculate number of miles and price.
milesInteger = endingInteger - beginningInteger
daysPriceDecimal = daysInteger * DAYS_PRICE_Decimal
milesPriceDecimal = MILES_PRICE_Decimal * milesInteger
totalChargeDecimal = milesPriceDecimal + daysPriceDecimal

' Format and display summary values.
.totalChargeTextBox.Text = totalChargeDecimal.ToString("C")
.milesTextBox.Text = milesInteger.ToString()

Catch beginningException As FormatException
' Handle a days driven exception.
MessageBox.Show("Beginning number of miles.", "Data Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With .beginningTextBox
.Focus()
.SelectAll()
End With
End Try
Try

Catch endingException As FormatException
' Handle a price exception.
MessageBox.Show("Ending number of miles.", "Data Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With .endingTextBox
.Focus()
.SelectAll()
End With
End Try
Try
Catch daysException As FormatException
' Handle a price exception.
MessageBox.Show("Days Rented.", "Data Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With .daysTextBox
.Focus()
.SelectAll()
End With
End Try
Catch anException As Exception
' Handle any other exception.
MessageBox.Show("Error: " & anException.Message)

End Try
End With
End Sub
Private Sub clearButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles clearButton.Click
' Clear previous amounts from the form.

With Me
.nameTextBox.Clear()
.addressTextBox.Clear()
.cityTextBox.Clear()
.stateTextBox.Clear()
.zipCodeTextBox.Clear()
.beginningTextBox.Clear()
.endingTextBox.Clear()
.milesTextBox.Clear()
.totalChargeTextBox.Clear()
With .daysTextBox
.Clear()
.Focus()
End With
End With
End Sub
Private Sub exitButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles exitButton.Click
'Exit the project.

Me.Close()
End Sub


End Class
SemChance
 
Posts: 0
Joined: Sun Feb 17, 2008 4:17 am

Postby sjmoore on Mon Feb 18, 2008 2:58 am

Try defining the value of daysInteger before using it in your multiplication.
sjmoore
 
Posts: 0
Joined: Mon Feb 18, 2008 2:40 am
Location: Carson City, NV


Who is online

Users browsing this forum: No registered users and 3 guests