Click here to Skip to main content
13,142,065 members (57,100 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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
Posted 10-Nov-12 15:04pm
Updated 10-Nov-12 15:11pm
Jason Gleim 10-Nov-12 22:01pm
Can you tell us what it is or isn't doing? Just saying you are having problems and posting the code isn't much to go on. Unfortunately the batteries in my hand-held mind reader are dead so you'll have to tell me what error you are getting.
Sergey Alexandrovich Kryukov 10-Nov-12 22:13pm
And I have difficulty to understand what exactly you call "VB". The code is absolutely unacceptable any way, even if it is worked. Please, no hard-coded immediate constants, no strings instead of numbers, 3.5, not "3.5"), no long "if". Do your work accurately, and then you can get the results.
Pablo Aliskevicius 11-Nov-12 7:03am
If your question is about homework, label it as such.
aodennison 12-Nov-12 16:49pm
Show code embedded in the form, So I can try compiling and running your code.
Describe what the project should do.
Describe what it does do.
Do not use single letter variable names.
Use Option Explicit, always.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The Builder Pattern may (or may not) be excessive for your exercise (presumably homework), however, it is so ideal for your scenaerio that many of the examples of how to use it actually use Pizza creation as the example (either that or cars).

Wikipedia, Builder Pattern[^]

A Google search for Builder Pattern should help, and searching for Builder Pattern Pizza will probably hand it to you on a plate, just leaving you to code the UI to use the classes the pattern implements. But do try and understand why it works...


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 25 Nov 2012
Copyright © CodeProject, 1999-2017
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