Question Help about decrement increment

sk11kur0chi

New member
Joined
Apr 2, 2014
Messages
2
Programming Experience
Beginner
im new to VB im using 2010 atm im making a reservation system about yacht my proffessor told me to add availability of the units so thats the reason why im here i tried different codes but didnt get my goal so pleace can you help me im a begginer btw. months of experience..

yacht = 20 units

each time someone reserved a yacht it should go down by 1 and by the time the reservation ended it should return to the number of available uniit i really need help thank you!!!
 
Um, the code to increment something looks like this:
something += 1
The code to decrement something looks like this:
something -= 1
How exactly to integrate that into your app depends completely on the code of your app, which we know nothing about. Show us where you think the code should go and what you think the code should look like and what happens when you try, e.g. any error messages, and we can help you fix the issue.
 
actually i dont have the codes yet(on this problem but i do have a working project atm) nothing i dont have any idea what to do it should appear on a single label

example (label1) 30 <---- this number represents the available number of units the customer will input the kind of yacht he will reserve then the 30w/c is the total

number of unit will be -1 then the customer will input the reservation time based on hours (maximum of 15.) after 15hrs it will auto update that the reservation ended

and the 29 units will + 1 and it would be 30 , sorry if my explanation is vague im really new to VB
 
sk11kur0chi, you can try this code if this works: (Button1 is reserve button)
Put this under the public class form line:

Dim units As Integer = 30 <-------no. of units

Private Sub Button1_Click
units -= 1
Label1.Text = units
End Sub

You will see that label1 will deduct in number each time you click the reserve button.. About the time, i dunno about that. I think timer is required for that and add conditions for your button..
 
You're both on the wrong track. The first thing you should do is put Option Strict On at the top of the code. This will enforce explicit type conversion and prevent subtle errors.

The number displayed in the label is text, which must be converted into a number before you can process it with a decrement counter.

In the button procedure, you will first obtain the value of the label (which is text), and convert it into a number. You will then use the decrement counter on that number. Finally, you will convert that new number back into a string and display it on the label as text.
 
Back
Top