Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB
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
Else
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
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
Edited 10-Nov-12 15:11pm
Nelek47.5K
v2
Comments
Jason Gleim at 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 at 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.
--SA
Pablo Aliskevicius at 11-Nov-12 7:03am
   
If your question is about homework, label it as such.
aodennison at 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
good
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...
 
M
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 540
1 Sergey Alexandrovich Kryukov 407
2 Yogesh Kumar Tyagi 384
3 Prakriti Goyal 280
4 Maciej Los 205
0 OriginalGriff 6,632
1 Sergey Alexandrovich Kryukov 5,429
2 Maciej Los 3,474
3 Peter Leow 3,309
4 DamithSL 2,495


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 25 Nov 2012
Copyright © CodeProject, 1999-2014
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