Skip to main content
GameDev.net gamedev.net
🔒 Locked

VB prob again

Started by thomashun Dec 5, 2001 at 7:39 AM 16 replies 650+ views
Original Post
thomashun
thomashun
Alright here it goes On one page we have lets say applecost another page has orangecost and another meloncost all currency. Now I want to add them all together on a different page should I put applecost, orangecost, etc into a module or what?
krez
krez
when you say "page" do you mean "form"? if not then don''t bother reading this because i don''t know what you are talking about.
you can
(1) make these variables public members of the form, and then get them with "FormName.VariableName", or
(2) make them global variables (in a module)


--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
thomashun
thomashun
Thank you and remember kids dont do drugs
thomashun
thomashun
What the hell is wrong with this?

TotalCost = Val(frmGuitar.guitar1cost) + Val(frmGuitar.guitar2cost) + Val(frmGuitarAcc.pedalcost) & _
Val(frmGuitarAcc2.GuitarPickCost) + Val(frmGuitarAcc2.GuitarStrapCost) & _
Val(frmGuitarAcc2.GuitarStringCost) + Val(frmAmp.guitarampcost) + Val(frmAmp.guitarampheadcost) & _
Val(frmBass.basscost) + Val(frmBassAcc.BassPickCost) + Val(frmBassAcc.BassStrapCost) & _
Val(frmBassAcc.BassStringCost) + Val(frmBassAmp.bassampcost) + Val(frmDrum.drumcost) & _
Val(frmSticks.stickcost)

txtTotalPrice.Text = TotalCost

not adding the cost up.

Edited by - thomashun on December 5, 2001 5:41:19 PM
Ironside
Ironside
How great is that, post your homework questions to gamedev.net.
jollyjeffers
jollyjeffers
that is pretty cheeky... GAMEdev.net, somehow implies (ot me) that it''s about games... what have the prices of melons and oranges got to do with games? lol. well, actually I''m just being harsh, maybe it''s a good game...

I''m tired. forget it.

Jack;
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
ragonastick
ragonastick
What is with the & signs at the ends of the lines, and are you using variant types? Variants are evil, avoid at all costs. & signs are for string... (trying to spell concatecaitsoin)... joining.

Trying is the first step towards failure.
Trying is the first step towards failure.
krez
krez
you must be sure that all those forms are loaded and have had the variables set to something... why exactly are you using this many forms for this type of thing?

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
a person
a person
maybe he dont know how to create boxes/labels/edit boxes/varibles/modify forms at runtime/the teacher said he better have a many forms or else!
thomashun
thomashun
I am making a program about instruments for one. I just used this as an example. Anysway, & _ means the line is too damn long and you bring it down to the next line.
thomashun
thomashun
I replaced the & with +''s but the damn things still doesnt work!?!
krez
krez
well, are you getting an error, or does it just give you the wrong number?
the code looks like it should work (syntax wise, it is still a messy way to do it)... what kind of variables are all those, and are you sure you are setting them?

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
thomashun
thomashun
ok the basscost, guitar1cost, etc are all public variables that are currency. They get there information from something like
guitar1cost = txtguitarprice * val(txtguitarquan).
Oh and there are NO errors popping up.

Edited by - thomashun on December 6, 2001 11:42:19 AM
krez
krez
hmmm... i can''t think of anything that would cause a problem there... maybe you are messing up with type conversions? i never used the currency type, but maybe it doesn''t work properly with VAL() or something... or maybe you have a problem going from text -> numbers, or numbers -> text...
you could try using SINGLEs instead of CURRENCY, and formatting to two decimal places for the output (not good if you are dividing and getting lotsa decimals, but for multiplying and adding it should be ok)...
if you want you can email me your project and i''ll look at it (make sure it is text though)...

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
jollyjeffers
jollyjeffers
txtGuitarPrice = a text box? well use "txtGuitarPrice.Text", just to be safe, what you''ve typed in just references the object TextBox... VB will usually work out what you mean, but maybe it''s not this time...

also, use CCurr() or CLng() to convert the string to a valid currency/long value before you try processing... again, Vb may be misinterpretting what you want...

Jack;
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.