PDA

View Full Version : Its not showing


Arbitus
2004-08-11, 04:57 PM
I have a button on one form that is the "buy" button. When someone clicks it it gives them a inputbox asking how many grams of heroin they want to buy :killgrin:, When they click this it finds out if they have enough money at first. Then if they do it subtracts how much it cost from there money and adds however many they wanted to the heroin variable (showing how many they have in there inventory) but when i go to the inventory it wont show up. But when you buy some buds it shows up. here it the buy button code:

Private Sub Command15_Click()
' buying heroin
buy = InputBox("How many do you want to buy", "How many?")
If buy * dheroin < cash Then
MsgBox ("You just bought " & buy & " grams of heroin")
final = buy * dheroin
cash = cash - final
heroin = heroin + buy
Else
MsgBox ("You dont have enough money")
End If
End Sub

Dheroin is how much the heroin costs. buy is the number the user wants to buy. final is how many they want to buy times how much it costs. cash is there current money, and heroin is the variable that stores how much heroin the user has.

On another form, the inventory page, it shows how much of each drug the user has and I have it set up so it will update the label that shows how much for heroin you have by setting the interaval on timer to 5. and when the 5 is up it just sets itself back to 5.

here is the timer script:

heroin1.Caption = heroin

heroin1 is the label.

BlueCube
2004-08-11, 06:52 PM
Hmm, is Heroin declared as a Public value? If not, you'll just get 0 every time. (And if it is, I'd say to make sure you didn't declare it as "Herion" or something by accident.)

Also, I'd really, REALLY recommend actually naming your command buttons to something useful, like cmdBuyHeroin. I cannot imagine attempting to figure out which command button is which using the code.

Edit: Also, why dHeroin instead of heroinCost or something?

Arbitus
2004-08-11, 10:32 PM
LOL I know my scripts are sloppy, they ussually arint. This whole game started as a joke but im having fun doing this so I decided to make it pretty big. Thanks for the help I will check it out some more.

EDIT: FIXED. alright here is what was wrong. I had a public variable called heroin and the name of one of the labels was heroin. so it was setting the label to "Buys" anyways THANKS!