Click here to Skip to main content
13,346,966 members (71,557 online)

Visual Basic Assignment - I'm having difficulties getting my code to work.

Ritchie Vasquez asked:

Open original thread
Hello! I'm currently working on a visual basic program but i just can't seem to get it working. I've tried everything that i know. Maybe i'm just not seeing it. It has me very impatient now. Please help me. I'll paste my code below:

Private Sub chktop_Click(Index As Integer)
'read toppings
PizzaTop = chktop(Index).Caption
End Sub

Private Sub cmdBuild_Click()
'message box
Dim message As String
Dim message2 As String
Dim I As Integer
Dim b As Double
Dim e As Double
Dim PizzaSize As String
Dim PizzaCrust As String
Dim PizzaWhere As String

If PizzaSize = small Then
b = 17
message = "Small" + "$17.00" + vbCr
End If
If PizzaSize = medium Then
b = 22
message = "Medium" + "$22.00" + vbCr
End If
If PizzaSize = large Then
b = 27
message = "Large" + "$27.00" + vbCr
End If
If PizzaWhere = eatin Then
b = b + 5
message = message + "EatIn" + "$5.00" + vbCr
If PizzaWhere = takeout Then
message = message + "TakeOut" + "$0.00" + vbCr
End If
End If

message = message + PizzaCrust + vbCr

For I = 0 To 6
If chktop(I).Value = vbChecked Then message = message + chktop(I).Caption + "$1.25" + vbCr
If chktop(I).Value = vbChecked Then b = b + 1.25
Next I
e = (b * 0.125) + b
message2 = message & "Your Total is " & e
MsgBox message2, vbOKOnly, "Your Pizza"

End Sub

Private Sub cmdExit_Click()
End Sub

Private Sub Form_Load()
'initialize pizza parameters
PizzaSize = "Small"
PizzaCrust = "Thin Crust"
PizzaWhere = "Eat In"
End Sub

Private Sub optCrust_Click(Index As Integer)
'read crust
PizzaCrust = optCrust(Index).Caption
End Sub

Private Sub optSize_Click(Index As Integer)
'read pizza size
PizzaSize = optSize(Index).Caption
End Sub

Private Sub optWhere_Click(Index As Integer)
'read Pizza eating location
PizzaWhere = optWhere(Index).Caption
End Sub
Tags: VB


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy |
Web01 | 2.8.180111.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100