|
-
Jun 22nd, 2006, 12:30 PM
#1
Thread Starter
Member
[RESOLVED] help
in VB i have this code to deducte resources for a place.
Do Until i <= 300
metal1 = ship2_no.Text * 300
metalt = CLng(Label1.Caption - metal1)
i = metalt < 300
MsgBox ("Not Enough")
i = i + 3
Loop
wot ive tried to do is this if i have enough for 6 items but i ask for 10 how to i make it stop on 6 and not do into - figures?
-
Jun 22nd, 2006, 12:48 PM
#2
Addicted Member
Re: help
Hey KPS,
I don't totally understand what you want. How about telling us more.
The only thing I can see is :
i = metalt < 300
This line is just setting i to true or false.
Do you mean :
If I < 300 then ...
If you want to exit the loop at this point then use Exit Do
Keith_VB6
If you have any further questions, just ask.
If this solves things, then please mark the thread resolved.
[Thread Tools] --> [Mark Thread Resolved]
-
Jun 22nd, 2006, 12:54 PM
#3
Thread Starter
Member
Re: help
that sounds rite ill give it a try thanks
-
Jun 22nd, 2006, 01:33 PM
#4
Thread Starter
Member
Re: help
okay ive taken the do out ive now got this
If ship2_no.Text Then
metal1 = ship2_no.Text * 300 ' this works out how much is needed eg 300 * 300
metalt = CLng(Label1.Caption - metal1) ' this sutracts amount 1000 - 900
If metal1 > 300 Then ' this part is where i want it to say if metal1 is more that how much we have then msgbox then only allow how many it can produce or dont allow any sort of thing
MsgBox ("Not Enough")
End If
End If
if that makes more sence
-
Jun 22nd, 2006, 02:05 PM
#5
Re: help
I dont understand? it looks like u have what you need...
VB Code:
If ship2_no.Text Then
metal1 = ship2_no.Text * 300
metalt = CLng(Label1.Caption - metal1)
If metal1 > 300 Then
MsgBox "Not Enough"
End If
End If
so if metal1 is more than 300 then say Not Enough?
also, on a side note, try to use the VBCODE tags around your code. makes it easier
to read...
Just click VBcode in the quick reply, then paste or type your code, then click VBCode again Thanks!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 22nd, 2006, 02:19 PM
#6
Thread Starter
Member
Re: help
should be
VB Code:
If metal1 > metalt Then msg box
wot happens is when i say 30 units for example ,it does this 30*300 then 10000 which is the total amount i have- 9000 which is the calculations total fantastic that works fine it deducts and everyones happy
if i order 40 at 300 cost 12000 then it does 10000 - 12000 im in the red as were by 2000.
i want it to say no carnt by all them then to end the process or build as many as allowed
-
Jun 22nd, 2006, 02:32 PM
#7
Re: help
something like this?
if too many then ask the user if they want to just use whats there...
if No.. exits sub
if yes.. then.. do your code
VB Code:
If ship2_no.Text Then
metal1 = ship2_no.Text * 300
metalt = CLng(Label1.Caption - metal1)
If metal1 > metalt Then
If MsgBox("Not enough to build that many! Would you like to use whats available? (" & _
Label1.Caption & ")", vbYesNo + vbQuestion, "Not Enough") = vbNo Then Exit Sub
metal1 = metalt
'do othe code..
End If
End If
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 22nd, 2006, 03:32 PM
#8
Addicted Member
Re: help
It looks like Static is heading you in the right direction. How about this slight tweak ?
VB Code:
If ship2_no.Text Then
metal1 = ship2_no.Text * 300
metalt = CLng(Label1.Caption - metal1)
If metal1 > metalt Then
If MsgBox("Not enough to build that many! Would you like to use whats available? (" & _
Label1.Caption & ")", vbYesNo + vbQuestion, "Not Enough") = vbNo Then Exit Sub
metal1 = metalt
'do othe code... Build the maximum amount
Else
'there's enough, so build it.
End If
End If
Keith_VB6
If you have any further questions, just ask.
If this solves things, then please mark the thread resolved.
[Thread Tools] --> [Mark Thread Resolved]
-
Jun 22nd, 2006, 06:26 PM
#9
Thread Starter
Member
Re: help
i will try this thanks guys
/me wishes i didnt start this project. Once its finished ill publish it ok here for more info visit www.mmfak.co.uk/sw.htm i think it is or just go to www.mmfak.co.uk click on links and its the sub_wars link
Last edited by KPS.; Jun 23rd, 2006 at 09:40 AM.
-
Jun 23rd, 2006, 09:42 AM
#10
Thread Starter
Member
Last edited by KPS.; Jun 23rd, 2006 at 09:51 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|