3 Replies - 1560 Views - Last Post: 18 May 2010 - 04:26 PM Rate Topic: -----

#1 Sadek  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-May 10

VB CALCULATOR APPLICATION

Posted 18 May 2010 - 04:00 PM

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim decweight As Decimal
Dim decdistance As Decimal
Dim decshippingrate As Decimal
Dim deccharges As Decimal

decweight = CDec(TextBox1.Text)
decdistance = CDec(TextBox2.Text)

Select Case decweight
Case Is < 2
decshippingrate = 0.01D
Case Is 2 to 6
decshippingrate = 0.015
Case Is 6 to 10
decshippingrate = 0.02
Case Is 10 to 20
decshippingrate = 0.025


*(IM GETTING AN ERROR MESSAGE ONLY THE TOP OF THIS CODE WHICH STATES THAT RELATIONAL OPERATOR IS EXPECT)** IM HAVING TROUBLES TRYING TO USE THE GREATER THAN OR LESS THAN SIGNZ


End Select

deccharges = decshippingrate * decdistance

Label4.Text = deccharges.ToString("c")
End Sub
End Class

Is This A Good Question/Topic? 0
  • +

Replies To: VB CALCULATOR APPLICATION

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1062
  • View blog
  • Posts: 4,138
  • Joined: 02-July 08

Re: VB CALCULATOR APPLICATION

Posted 18 May 2010 - 04:09 PM

Select Case decweight
Case Is < 2
decshippingrate = 0.01D
Case 2 to 5
decshippingrate = 0.015
Case 6 to 10
decshippingrate = 0.02
Case 11 to 20
decshippingrate = 0.025
Case Is > 20
'something else



You had some overlapping cases, and I fixed the ones that don't use Is.
Was This Post Helpful? 0
  • +
  • -

#3 Sadek  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-May 10

Re: VB CALCULATOR APPLICATION

Posted 18 May 2010 - 04:22 PM

Thanks how do I exclude weights less than 0 and greater than 20 kg
and distances less than 10miles and greater than 3000miles
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1062
  • View blog
  • Posts: 4,138
  • Joined: 02-July 08

Re: VB CALCULATOR APPLICATION

Posted 18 May 2010 - 04:26 PM

Select Case will only use what fits, you can use the Case Else at the end for anything that falls out of the parameters.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1