Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




1414 posts

Uber Geek
+1 received by user: 11


Topic # 68478 22-Sep-2010 19:22
Send private message

hi there,
i have some coding for Vb6 as follows

'lets start on vanweight issue

vanweight2 = Val(frmReceipt.lblWeight.Caption)

vanweight = vanweight + vanweight2 'sets weight to add on each time to vanweight
vanleft = (250 - vanweight)



If vanleft < 0 Then
MsgBox ("VAN OVERLOAD"), vbOKOnly + vbExclamation, " Van Capacity Has Been Exceeded"
frmTicket.Show 'takes user back to ticket form
Unload frmReceipt 'unloads receipt form



The problem im having is when the variable "vanleft" is below 0 (in the if statement above)
the message box with VAN OVERLOAD comes up perfectly, however the value of vanleft remains below zero. Im looking for help on how to leave vanleft unchanged if vanleft < 0

for example, a user enters 3 values for weight

50kg
100kg
110kg

the result for vanleft will be (250-50-100-110) vanleft = -10

when vanleft is below 0, i want the last value to be removed. So when a user puts these 3 values in, the message box appears, to say van overload, then the value they LAST input, is removed. and vanleft will only equal 150kg.

please help me, i have spent hours looking at this code :S
thanks in advance




gz ftw


Create new topic
1366 posts

Uber Geek
+1 received by user: 16


  Reply # 383331 22-Sep-2010 19:56
Send private message

ok i think i understand your question, you just need to modify the if statement:

If vanweight - 250 > 0 Then

vanleft = (250 - vanweight) //add this inside the if statement


Else //vanleft would be less than 0 so error

MsgBox ("VAN OVERLOAD"), vbOKOnly + vbExclamation, " Van Capacity Has Been Exceeded"
frmTicket.Show 'takes user back to ticket form
Unload frmReceipt 'unloads receipt form


Hope this helps :)



1414 posts

Uber Geek
+1 received by user: 11


  Reply # 383335 22-Sep-2010 20:11
Send private message

your a legend !
thanks very much mate.

i understand what i did now... i always had the vanleft variable resulting in a number below 0.
all sorted now and going good.
have a good night




gz ftw


 
 
 
 




1414 posts

Uber Geek
+1 received by user: 11


  Reply # 383336 22-Sep-2010 20:11
Send private message

woot 300th post :D




gz ftw


1366 posts

Uber Geek
+1 received by user: 16


  Reply # 383337 22-Sep-2010 20:11
Send private message

no worries :)

Create new topic



Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Geekzone Live »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.