Visual Basic Program

Associate
OP
Joined
17 Nov 2011
Posts
852
What help are you actually asking for?
I'm completely stuck and if possible for someone to complete the code of the program for me

You really need to name your controls properly.
Don't use the TextChanged event or you are going to get into trouble really quickly. Use a button somewhere call it calculate and use that to run the calculations.
Thanks for the suggestion, I'll edit the layout
 
Associate
OP
Joined
17 Nov 2011
Posts
852
You could put the controls into a frame and then disabling the frame locks the controls. Or you could disable them individually remembering to re enable them when the user clicks on the No.
How do I do that?

Yes, but you wouldn't want to. What happens if they accidently click on No and change their mind? You've just disabled the control with no way of putting it back.
Good thinking, what would be the best way to do it?

Text boxes are for data collection. You can disable them, but they go grey.
For displaying information like costs, turn them into Labels.
Thanks, I'll change them to Labels
 
Associate
OP
Joined
17 Nov 2011
Posts
852
As I said before I'd have the collect option in a drop down list with all the other delivery options. However if you want to stick with one set of options for collection/delivery and one for delivery code then I would use the click event of each of the collection/delivery radio controls to change whether you can click on the delivery code controls. It might even be a good idea to clear the selected delivery option if they select collection.
I've thought about it and have gone with your decision, I've changed it to one section with ComboBox,

vzE.jpg


If user select Collect or Delivery Code C then delivery price will be FREE which is 0, but if user select Other and depending on how many lunches is ordered, if less than 10 lunches, it will cost £2.50 delivery but if 10 or more lunches ordered, it will be FREE which is 0
 
Associate
OP
Joined
17 Nov 2011
Posts
852
Sorry, I kind of forgot about this thread.
How far have you got now?
I've changed the Delivery option to ComboBox with selection,

vzE.jpg


If user select Collect or Delivery Code C then delivery price will be FREE which is 0, but if user select Other and depending on how many lunches is ordered, if less than 10 lunches, it will cost £2.50 delivery but if 10 or more lunches ordered, it will be FREE which is 0

Also I've changed Textboxes to Labels, how do I make the Label visible so I can click on them and change them as I can't change them when I don't name them
 
Associate
OP
Joined
17 Nov 2011
Posts
852
I've changed the Delivery option to ComboBox with selection,

vzE.jpg


If user select Collect or Delivery Code C then delivery price will be FREE which is 0, but if user select Other and depending on how many lunches is ordered, if less than 10 lunches, it will cost £2.50 delivery but if 10 or more lunches ordered, it will be FREE which is 0

Also how do I put currency on the Cost label?
 
Associate
OP
Joined
17 Nov 2011
Posts
852
It's just text. Put in what you want.
The labels display the costs correctly, but without currency, I want to add £ sign before the number in the Label, but I don't know how

Also if the user select Collect or Delivery Code C then delivery price will be FREE which is 0, but if user select Other and depending on how many lunches is ordered, if less than 10 lunches, it will cost £2.50 delivery but if 10 or more lunches ordered, it will be FREE which is 0, I need help on the coding

vzE.jpg
 
Associate
OP
Joined
17 Nov 2011
Posts
852
You want to construct a string with the currency symbol and cost and the set the label text to that; for example -
Code:
Label.text = "currency-symbol" & intCost
Do I add the string code to the Label or the textbox above?

Personally I'd have
label.text = "£" & fCost.toString
or
label.text = string.concat("£",fCost.toString)
or
dim sb as New System.Text.stringbuilder
sb.append("£")
sb.append(fCost.toString)
label.text = sb.toString
Where do I add the string code?

You don't appear to have got any further with this since the 3rd or even tried to do any more.
I tried to code it but when I run it, it says there are problems

Are actually trying to learn this or do you just want the answer? If so I can send you an exe for you to run.
This is my first practise to code in Visual Basic, I was hoping to get it all coded done so I can see the example for my next practise

I've sent you the program via Trust
 
Associate
OP
Joined
17 Nov 2011
Posts
852
You might want to read up on basic programming principles. Maybe start with a few Hello World! programs with online code.

To make the text on a label change you reference it and set it's text property to a string value.
in the examples above:

Label1 is the object on the screen that you are trying to affect. Yours is lblMealCost or something.
.text is the property of the object that you are trying to change.
= is assigning the value on the right of it to the property on the left.
"£" is a string value in this case a pound sign.
& is a for concatenation of strings.
fCost is a variable that contains the price that the calculation routing sets so 2.50 etc.
.toString() is a method of the object (in this case a float containing 2.50) which make the number into a string.

so you end up with

Label1.text = "£" & fCost.toString

This replaces whatever line currently set the value of the label you said is displaying the costs. remember to change the label object and the float object to match your code.
Thanks, I'll alter the code, but is it possible for you to help me finish the coding of Delivery and Calculate part so I can use this program as a example for my next practise please

I'll have a look at the tutorials
 
Back
Top Bottom