Small Prob :(
im kinda new to vb and i tried to write a program to calculate something for a game. But, i keep gettin the "BLock if withough End if" error. I would appreciate if someone can help me out with this.
private Sub cmdCalculate_Click()
Dim xp as Variant
Dim lvl as Integer
Dim lvlxp as Long
Dim material as string
Dim answer as Integer
Dim materialxp as Integer
Dim clay as string
Dim copper as string
Dim iron as string
Dim tin as string
Dim silver as string
Dim coal as string
Dim gold as string
Dim mith as string
Dim adamantite as string
Dim rune as string
lvl = Val(txtLvl.Text)
xp = Val(txtXp.Text)
material = Trim(txtMine.Text)
If lvl = 1 then
lvlxp = 0:
ElseIf lvl = 2 then
lvlxp = 83:
ElseIf lvl = 3 then
lvlxp = 174:
ElseIf lvl = 4 then
lvlxp = 276:
ElseIf lvl = 5 then
lvlxp = 388:
ElseIf lvl = 6 then
lvlxp = 512:
ElseIf lvl = 7 then
lvlxp = 650:
ElseIf lvl = 8 then
lvlxp = 801:
ElseIf lvl = 9 then
lvlxp = 969:
If lvl = 10 then
lvlxp = 1154:
ElseIf lvl = 11 then
lvlxp = 1358:
ElseIf lvl = 12 then
lvlxp = 1584:
ElseIf lvl = 13 then
lvlxp = 1833:
ElseIf lvl = 14 then
lvlxp = 2107:
ElseIf lvl = 15 then
lvlxp = 2411:
ElseIf lvl = 16 then
lvlxp = 2746:
ElseIf lvl = 17 then
lvlxp = 3115:
ElseIf lvl = 18 then
lvlxp = 3523:
ElseIf lvl = 19 then
lvlxp = 3973:
ElseIf lvl = 20 then
lvlxp = 4470:
ElseIf lvl = 21 then
lvlxp = 5018:
ElseIf lvl = 22 then
lvlxp = 5624:
ElseIf lvl = 23 then
lvlxp = 6291:
ElseIf lvl = 24 then
lvlxp = 7028:
ElseIf lvl = 25 then
lvlxp = 7842
else
MsgBox "Please Enter A Number From 1 to 99", "error :P"
End If
If material = clay then
materialxp = 5:
ElseIf material = tin then
materialxp = 17.5:
ElseIf material = copper then
materialxp = 17.5:
ElseIf material = iron then
materialxp = 35:
ElseIf material = silver then
materialxp = 40:
ElseIf material = coal then
materialxp = 50:
ElseIf material = gold then
materialxp = 65:
ElseIf material = mith then
materialxp = 80:
ElseIf material = adamantite then
materialxp = 95:
ElseIf material = rune then
materialxp = 125:
else
MsgBox "Please Enter either : clay, tin, copper, iron, silver, coal, gold, mith, adamantite or rune", "error :P"
End If
answer = (lvlxp - xp) / materialxp
lblAnswer.Caption = answer & material
lblAnswer.Alignment = 2
End Sub
# 1 Re: Small Prob :(
Kill all those If stats and try using a 'Select Case' stat:
Dim I
I = "something"
Select case I
Case "something"
'put code in this
Case else
'put code in this
end select
------------
Rowan Lewis of Lewis Software Australia
rowan@bootbox.net - lsa.esmartweb.com
# 2 Re: Small Prob :(
Line 39 (?) is the culprit. It should be another ElseIF, not IF:
ElseIf lvl = 10 Then
aio at 2007-11-10 0:34:38 >

# 3 Re: Small Prob :(
Ty, i changed it and now im gettin somethin wrong with the MsgBox lines... sigh..
and i will try also with the select case.
# 4 Re: Small Prob :(
Nm, dunno why i put
, "error :P"
thought it was something else...
# 5 Re: Small Prob :(
... and by the way, just a tip. You can do it better with an array.
aio at 2007-11-10 0:37:44 >

# 6 Re: Small Prob :(
When i said i was new to vb i really meant it :), can u gimme an example of an array plz?
# 7 Re: Small Prob :(
Hold 10 for updated code :-)
------------
Rowan Lewis of Lewis Software Australia
rowan@bootbox.net - lsa.esmartweb.com
# 8 Re: Small Prob :(
Replace the code with this:
private Sub cmdCalculate_Click()
Dim xp as Variant
Dim lvl as Integer
Dim lvlxp as Long
Dim material as string
Dim answer as Integer
Dim materialxp as Integer
Dim clay as string
Dim copper as string
Dim iron as string
Dim tin as string
Dim silver as string
Dim coal as string
Dim gold as string
Dim mith as string
Dim adamantite as string
Dim rune as string
'---------
lvl = Val(txtLvl.Text)
xp = Val(txtXp.Text)
material = Trim(txtMine.Text)
Select Case lvl
Case 1
lvlxp = 0:
Case 2
lvlxp = 83:
Case 3
lvlxp = 174:
Case 4
lvlxp = 276:
Case 5
lvlxp = 388:
Case 6
lvlxp = 512:
Case 7
lvlxp = 650:
Case 8
lvlxp = 801:
Case 9
lvlxp = 969:
Case 10
lvlxp = 1154:
Case 11
lvlxp = 1358:
Case 12
lvlxp = 1584:
Case 13
lvlxp = 1833:
Case 14
lvlxp = 2107:
Case 15
lvlxp = 2411:
Case 16
lvlxp = 2746:
Case 17
lvlxp = 3115:
Case 18
lvlxp = 3523:
Case 19
lvlxp = 3973:
Case 20
lvlxp = 4470:
Case 21
lvlxp = 5018:
Case 22
lvlxp = 5624:
Case 23
lvlxp = 6291:
Case 24
lvlxp = 7028:
Case 25
lvlxp = 7842:
Case else
MsgBox "Please Enter A Number From 1 to 99", "error :P"
End Select
Select Case material
Case clay
materialxp = 5:
Case tin
materialxp = 17.5:
Case copper
materialxp = 17.5:
Case iron
materialxp = 35:
Case silver
materialxp = 40:
Case coal
materialxp = 50:
Case gold
materialxp = 65:
Case mith
materialxp = 80:
Case adamantite
materialxp = 95:
Case rune
materialxp = 125:
Case else
MsgBox "Please Enter either : clay, tin, copper, iron, silver, coal, gold, mith, adamantite or rune", "error :P"
End Select
answer = (lvlxp - xp) / materialxp
lblAnswer.Caption = answer & material
lblAnswer.Alignment = 2
End Sub
If you wan't i will make more changes to make it better!
------------
Rowan Lewis of Lewis Software Australia
rowan@bootbox.net - lsa.esmartweb.com
# 9 Re: Small Prob :(
Ty, that is better :D. BUT, how do you dim somethin that may have a value that can reach 13 mil? ANd also, what is an array :D?
# 10 Re: Small Prob :(
You might have to ask aio because i have never used arays before!
------------
Rowan Lewis of Lewis Software Australia
rowan@bootbox.net - lsa.esmartweb.com
# 11 Re: Small Prob :(
ok, thx, and whats the data type for a variable that can reach 13 000 000 ? is it long? or osmethign else?
# 12 Re: Small Prob :(
Sorry i cant say because i don't know and i don't have a copy of VB on this PC!
But i have something to make your code look more prolike:
Add this to the top:
Dim Title, Message, Buttons
Replace the first msgbox with this:
Title = "error : Invalid option"
Message = "Please Enter A Number From 1 to 99"
Buttons = vbOKOnly
Call MsgBox(Message, Buttons, Title)
The second with this:
Title = "error : Invalid option"
Message = "Please Enter either : clay, tin, copper, iron, silver, coal, gold, mith, adamantite or rune"
Buttons = vbOKOnly
Call MsgBox(Message, Buttons, Title)
------------
Rowan Lewis of Lewis Software Australia
rowan@bootbox.net - lsa.esmartweb.com
# 13 Re: Small Prob :(
Dont worry Pal. I was in the same shoes 10 years ago when no VB people around me and no internet (and dev-archive) to turn to terrible pain. ;p
option Explicit
' We can declare an array like this.. This is called a dynamic array,
' .. meaning, we dont know in advance how many values our array will eventually contain.
Dim LevelXp() as Integer
' If you are sure that you array will contain a certain number of elements,
' you can declare it as: Dim LevelXp(25) as Integer
'This is call a User-Defined Type (UDT) variable
' .. in simple terms, a variable that contains many types of data (sub-variable?)
private Type MaterialType
Description as string
Expense as Currency
End Type
' we will also put our UDT into an array -- dynamic
Dim Material() as MaterialType
'
private Sub Form_Load()
' when we load our form, make sure that our arrays will contain the values needed
InitializeMyArrays
cmdCalculate_Click
End Sub
'
'
private Sub InitializeMyArrays()
' we can now resize our array to the right size
' NOTE: we know it's 25. If not, we have to do something
' to get that value. --not at this time.
ReDim LevelXp(25) as Integer
LevelXp(1) = 0
LevelXp(2) = 83
LevelXp(3) = 174
LevelXp(4) = 276
LevelXp(5) = 388
LevelXp(6) = 512
LevelXp(7) = 650
LevelXp(8) = 801
LevelXp(9) = 969
LevelXp(10) = 1154
LevelXp(11) = 1358
LevelXp(12) = 1584
LevelXp(13) = 1833
LevelXp(14) = 2107
LevelXp(15) = 2411
LevelXp(16) = 2746
LevelXp(17) = 3115
LevelXp(18) = 3523
LevelXp(19) = 3973
LevelXp(20) = 4470
LevelXp(21) = 5018
LevelXp(22) = 5624
LevelXp(23) = 6291
LevelXp(24) = 7028
LevelXp(25) = 7842
' this is how we assign values to our UDT array
ReDim Material(10) as MaterialType
Material(1).Description = "CLAY": Material(1).Expense = 5
Material(2).Description = "TIN": Material(2).Expense = 17.5
Material(3).Description = "COPPER": Material(3).Expense = 17.5
Material(4).Description = "IRON": Material(4).Expense = 35
Material(5).Description = "SILVER": Material(5).Expense = 40
Material(6).Description = "COAL": Material(6).Expense = 50
Material(7).Description = "GOLD": Material(7).Expense = 65
Material(8).Description = "MITH": Material(8).Expense = 80
Material(9).Description = "ADAMANTITE": Material(9).Expense = 95
Material(10).Description = "RUNE": Material(10).Expense = 125
End Sub
private Sub cmdCalculate_Click()
Dim lvl as Integer
Dim XP as Integer
Dim ThisMaterial as string
Dim answer as Single 'converted to single because some result maybe in fractions
Dim I as Integer
Dim MatIndex as Integer
lvl = Val(txtLvl.Text)
XP = Val(txtXp.Text)
' ok -- lets convert to upper case so it would be comparable because
' our values was inputted in upper case
ThisMaterial = UCase(Trim(txtMine.Text))
' make sure we get only the value within the bounds of our array...
If lvl < 1 Or lvl > 25 then
' ... if not, i just copied and corrected your message. I don't why you choose this "error :P"
MsgBox "Please Enter A Number From 1 to 25", vbOKOnly, "error :P"
else
' if we get the correct bounds, let try searching for our material descriptions
MatIndex = 0
' by just reading each array under description
for I = 1 to 25
If ThisMaterial = Material(I).Description then
' if we got it, take note of it
MatIndex = I: Exit for ' and discontinue searching, we don't the rest.
End If
next
' NOTE: if our array is very large, this is not a very efficient method of searching.
' It's a bit complicated business. let's just go there later when you're ready for
' a more painful test. ;-)
'
If MatIndex = 0 then
' if MatIndex remains 0, we did not find our description
MsgBox "Please Enter either : clay, tin, copper, iron, silver, coal, gold, mith, adamantite or rune", vbOKOnly, "error :P"
else
If Material(MatIndex).Expense = 0 then
' NOTE: we have zero in our material expense. we might run into trouble
' because computers (and mathematicians) could not divide by zero.
' Just do something here.
MsgBox "Material Expense is 0, computers (and mathematicians) could not divide by zero "
else
' take note how we extract the data from array. we use an index or pointer to the value
' lvl, for instance, instead of terrible IF-ElseIfs, we can just point to it.
answer = (LevelXp(lvl) - XP) / Material(MatIndex).Expense
' answer is an SINGLE, lets convert it to string.
' Try checking Format functions to display your value in correct format.
lblAnswer.Caption = CStr(answer) & " " & Material(MatIndex).Description
lblAnswer.Alignment = 2
End If
End If
End If
End Sub
There are lot's of things about arrays (multi dimentional, multi-level, multi?, etc). Just experiment on this first. Let's just proceed later when you're ready.
aio at 2007-11-10 0:45:56 >

# 14 Re: Small Prob :(
You may also check this post:
http://www.dev-archive.com/cgi-bin/bbs/wt/showpost.pl?Board=vb&Number=81745&page=0&view=collapsed&sb=5
I have here an example (PicFiles()) on how an array size changed dynamically by reading the number of files found.
aio at 2007-11-10 0:46:50 >

# 15 Re: Small Prob :(
I can't say this any other way...
... You Rule!
------------
Rowan Lewis of Lewis Software Australia
rowan@bootbox.net - lsa.esmartweb.com
# 16 Re: Small Prob :(
No. We share. Thanks.
aio at 2007-11-10 0:49:00 >

# 17 Re: Small Prob :(
Err... ok then!
I have another question about how to floodfill a picturebox below this please ava alook!
------------
Rowan Lewis of Lewis Software Australia
rowan@bootbox.net - lsa.esmartweb.com
# 18 Re: Small Prob :(
I can't recall the methods if any. Anyway, try this and just adjust the value of X1, X2, Y1, Y2, and color value.
private Sub Command1_Click()
DrawRegion 1, 100, 10, 100, QBColor(0)
End Sub
Sub DrawRegion(X1, X2, Y1, Y2, ColorVal as Long)
Dim i as Long
Dim j as Long
for i = X1 to X2
for j = Y1 to Y2
Picture1.PSet (i, j), ColorVal
next
next
End Sub
aio at 2007-11-10 0:50:54 >

# 19 Re: Small Prob :(
Opps! I forgot. Picture1's ScaleMode was set to 3 (Pixel).
aio at 2007-11-10 0:52:03 >

# 20 Re: Small Prob :(
Thx a lotto both of you ! :D Im gonna try the array now. Looks tricky but not that hard! Thx again !
# 21 Re: Small Prob :(
ok, this is what my code for the entire little program looks like and is workin fine. i will try to do this with the array like you showed me and i will post it here with any probs :). thx again :)
option Explicit
'Calculates how many more you have to mine to reach certain lvl
private Sub cmdCalculate_Click()
Dim xp as Variant
Dim lvl as Integer
Dim lvlxp as Long
Dim answer as Long
Dim materialxp as Integer
Dim title, message, buttons
lvl = Val(txtLvl.Text)
xp = Val(txtXp.Text)
If lvl = 1 then
lvlxp = 0:
ElseIf lvl = 2 then
lvlxp = 83:
ElseIf lvl = 3 then
lvlxp = 174:
ElseIf lvl = 4 then
lvlxp = 276:
ElseIf lvl = 5 then
lvlxp = 388:
ElseIf lvl = 6 then
lvlxp = 512:
ElseIf lvl = 7 then
lvlxp = 650:
ElseIf lvl = 8 then
lvlxp = 801:
ElseIf lvl = 9 then
lvlxp = 969:
ElseIf lvl = 10 then
lvlxp = 1154:
ElseIf lvl = 11 then
lvlxp = 1358:
ElseIf lvl = 12 then
lvlxp = 1584:
ElseIf lvl = 13 then
lvlxp = 1833:
ElseIf lvl = 14 then
lvlxp = 2107:
ElseIf lvl = 15 then
lvlxp = 2411:
ElseIf lvl = 16 then
lvlxp = 2746:
ElseIf lvl = 17 then
lvlxp = 3115:
ElseIf lvl = 18 then
lvlxp = 3523:
ElseIf lvl = 19 then
lvlxp = 3973:
ElseIf lvl = 20 then
lvlxp = 4470:
ElseIf lvl = 21 then
lvlxp = 5018:
ElseIf lvl = 22 then
lvlxp = 5624:
ElseIf lvl = 23 then
lvlxp = 6291:
ElseIf lvl = 24 then
lvlxp = 7028:
ElseIf lvl = 25 then
lvlxp = 7842:
ElseIf lvl = 26 then
lvlxp = 8740:
ElseIf lvl = 27 then
lvlxp = 9730:
ElseIf lvl = 28 then
lvlxp = 10824:
ElseIf lvl = 29 then
lvlxp = 12031:
ElseIf lvl = 30 then
lvlxp = 13364:
ElseIf lvl = 31 then
lvlxp = 14833:
ElseIf lvl = 32 then
lvlxp = 16456:
ElseIf lvl = 33 then
lvlxp = 18249:
ElseIf lvl = 34 then
lvlxp = 20224:
ElseIf lvl = 35 then
lvlxp = 22406:
ElseIf lvl = 36 then
lvlxp = 24815:
ElseIf lvl = 37 then
lvlxp = 27473:
ElseIf lvl = 38 then
lvlxp = 30408:
ElseIf lvl = 39 then
lvlxp = 33648:
ElseIf lvl = 40 then
lvlxp = 37224:
ElseIf lvl = 41 then
lvlxp = 41171:
ElseIf lvl = 42 then
lvlxp = 45529:
ElseIf lvl = 43 then
lvlxp = 50339:
ElseIf lvl = 44 then
lvlxp = 55649:
ElseIf lvl = 45 then
lvlxp = 61512:
ElseIf lvl = 46 then
lvlxp = 67983:
ElseIf lvl = 47 then
lvlxp = 75127:
ElseIf lvl = 48 then
lvlxp = 83014:
ElseIf lvl = 49 then
lvlxp = 91720:
ElseIf lvl = 50 then
lvlxp = 101333:
ElseIf lvl = 51 then
lvlxp = 111945:
ElseIf lvl = 52 then
lvlxp = 123660:
ElseIf lvl = 53 then
lvlxp = 136549:
ElseIf lvl = 54 then
lvlxp = 150872:
ElseIf lvl = 55 then
lvlxp = 166636:
ElseIf lvl = 56 then
lvlxp = 184040:
ElseIf lvl = 57 then
lvlxp = 203254:
ElseIf lvl = 58 then
lvlxp = 224466:
ElseIf lvl = 59 then
lvlxp = 247886:
ElseIf lvl = 60 then
lvlxp = 273742:
ElseIf lvl = 61 then
lvlxp = 302288:
ElseIf lvl = 62 then
lvlxp = 333804:
ElseIf lvl = 63 then
lvlxp = 368559:
ElseIf lvl = 64 then
lvlxp = 407015:
ElseIf lvl = 65 then
lvlxp = 449428:
ElseIf lvl = 66 then
lvlxp = 496254:
ElseIf lvl = 67 then
lvlxp = 547953:
ElseIf lvl = 68 then
lvlxp = 605032:
ElseIf lvl = 69 then
lvlxp = 668051:
ElseIf lvl = 70 then
lvlxp = 737627:
ElseIf lvl = 71 then
lvlxp = 814445:
ElseIf lvl = 72 then
lvlxp = 899257:
ElseIf lvl = 73 then
lvlxp = 992895:
ElseIf lvl = 74 then
lvlxp = 1096278:
ElseIf lvl = 75 then
lvlxp = 1210421:
ElseIf lvl = 76 then
lvlxp = 1336443:
ElseIf lvl = 77 then
lvlxp = 1475581:
ElseIf lvl = 78 then
lvlxp = 1629200:
ElseIf lvl = 79 then
lvlxp = 1798808:
ElseIf lvl = 80 then
lvlxp = 1986068:
ElseIf lvl = 81 then
lvlxp = 2192818:
ElseIf lvl = 82 then
lvlxp = 2421087:
ElseIf lvl = 83 then
lvlxp = 2673114:
ElseIf lvl = 84 then
lvlxp = 2951373:
ElseIf lvl = 85 then
lvlxp = 3258594:
ElseIf lvl = 86 then
lvlxp = 3597792:
ElseIf lvl = 87 then
lvlxp = 3972294:
ElseIf lvl = 88 then
lvlxp = 4385776:
ElseIf lvl = 89 then
lvlxp = 4842295:
ElseIf lvl = 90 then
lvlxp = 5346332:
ElseIf lvl = 91 then
lvlxp = 5902831:
ElseIf lvl = 92 then
lvlxp = 6517253:
ElseIf lvl = 93 then
lvlxp = 7195629:
ElseIf lvl = 94 then
lvlxp = 7944614:
ElseIf lvl = 95 then
lvlxp = 8771558:
ElseIf lvl = 96 then
lvlxp = 9684577:
ElseIf lvl = 97 then
lvlxp = 10692629:
ElseIf lvl = 98 then
lvlxp = 11805606:
ElseIf lvl = 99 then
lvlxp = 13034431:
else
title = "error :P Invalid option"
message = "Please Enter A Number From 1 to 99 for the lvl you wish to reach!"
buttons = vbOKOnly
Call MsgBox(message, buttons, title)
lblAnswer.Caption = ""
lblanswer2.Caption = ""
End If
If Trim(txtMine.Text) = "clay" then
materialxp = 5
ElseIf Trim(txtMine.Text) = "tin" then
materialxp = 17.5
ElseIf Trim(txtMine.Text) = "copper" then
materialxp = 17.5
ElseIf Trim(txtMine.Text) = "iron" then
materialxp = 35
ElseIf Trim(txtMine.Text) = "silver" then
materialxp = 40
ElseIf Trim(txtMine.Text) = "coal" then
materialxp = 50
ElseIf Trim(txtMine.Text) = "gold" then
materialxp = 65
ElseIf Trim(txtMine.Text) = "mith" then
materialxp = 80
ElseIf Trim(txtMine.Text) = "adamantite" then
materialxp = 95
ElseIf Trim(txtMine.Text) = "rune" then
materialxp = 125
else
title = "error :P Invalid option"
message = "Please Enter either : clay, tin, copper, iron, silver, coal, gold, mith, adamantite or rune!"
buttons = vbOKOnly
Call MsgBox(message, buttons, title)
lblAnswer.Caption = ""
lblanswer2.Caption = ""
End If
Select Case materialxp
Case is > 0
answer = (lvlxp - xp) / materialxp
lblAnswer.Caption = answer
lblAnswer.Alignment = 1
lblanswer2.Caption = Trim(txtMine.Text)
lblanswer2.Alignment = 2
Case is < 0
lblAnswer.Caption = ""
lblanswer2.Caption = ""
End Select
End Sub
private Sub cmdExit_Click()
End
End Sub
private Sub Command1_Click()
txtMine.Text = ""
txtLvl.Text = ""
lblAnswer.Caption = ""
lblanswer2.Caption = ""
txtXp.Text = ""
End Sub
# 22 Re: Small Prob :(
ok, i modified it and got the idea on how to use it. but, i get this error message Expected array and it highlights the word material on line
If thismaterial = material(I).description then
it highlights the word material and says expeted array
and heres the enteire code
option Explicit
'Calculates how many more you have to mine to reach certain lvl
Dim lvlxp(99) as Long
private Type materialtype
description as string
expense as Integer
End Type
Dim material() as materialtype
private Sub initializemyarrays()
lvlxp(1) = 0
lvlxp(2) = 83
lvlxp(3) = 174
lvlxp(4) = 276
lvlxp(5) = 388
lvlxp(6) = 512
lvlxp(7) = 650
lvlxp(8) = 801
lvlxp(9) = 969
lvlxp(10) = 1154
lvlxp(11) = 1358
lvlxp(12) = 1584
lvlxp(13) = 1833
lvlxp(14) = 2107
lvlxp(15) = 2411
lvlxp(16) = 2746
lvlxp(17) = 3115
lvlxp(18) = 3523
lvlxp(19) = 3973
lvlxp(20) = 4470
lvlxp(21) = 5018
lvlxp(22) = 5624
lvlxp(23) = 6291
lvlxp(24) = 7028
lvlxp(25) = 7842
lvlxp(26) = 8740
lvlxp(27) = 9730
lvlxp(28) = 10824
lvlxp(29) = 12031
lvlxp(30) = 13364
lvlxp(31) = 14833
lvlxp(32) = 16456
lvlxp(33) = 18249
lvlxp(34) = 20224
lvlxp(35) = 22406
lvlxp(36) = 24815
lvlxp(37) = 27473
lvlxp(38) = 30408
lvlxp(39) = 33648
lvlxp(40) = 37224
lvlxp(41) = 41171
lvlxp(42) = 45529
lvlxp(43) = 50339
lvlxp(44) = 55649
lvlxp(45) = 61512
lvlxp(46) = 67983
lvlxp(47) = 75127
lvlxp(48) = 83014
lvlxp(49) = 91720
lvlxp(50) = 101333
lvlxp(51) = 111945
lvlxp(52) = 123660
lvlxp(53) = 136549
lvlxp(54) = 150872
lvlxp(55) = 166636
lvlxp(56) = 184040
lvlxp(57) = 203254
lvlxp(58) = 224466
lvlxp(59) = 247886
lvlxp(60) = 273742
lvlxp(61) = 302288
lvlxp(62) = 333804
lvlxp(63) = 368559
lvlxp(64) = 407015
lvlxp(65) = 449428
lvlxp(66) = 496254
lvlxp(67) = 547953
lvlxp(68) = 605032
lvlxp(69) = 668051
lvlxp(70) = 737627
lvlxp(71) = 814445
lvlxp(72) = 899257
lvlxp(73) = 992895
lvlxp(74) = 1096278
lvlxp(75) = 1210421
lvlxp(76) = 1336443
lvlxp(77) = 1475581
lvlxp(78) = 1629200
lvlxp(79) = 1798808
lvlxp(80) = 1986068
lvlxp(81) = 2192818
lvlxp(82) = 2421087
lvlxp(83) = 2673114
lvlxp(84) = 2951373
lvlxp(85) = 3258594
lvlxp(86) = 3597792
lvlxp(87) = 3972294
lvlxp(88) = 4385776
lvlxp(89) = 4842295
lvlxp(90) = 5346332
lvlxp(91) = 5902831
lvlxp(92) = 6517253
lvlxp(93) = 7195629
lvlxp(94) = 7944614
lvlxp(95) = 8771558
lvlxp(96) = 9684577
lvlxp(97) = 9684577
lvlxp(98) = 11805606
lvlxp(99) = 13034431
ReDim material(10) as materialtype
material(1).description = "clay": material(1).expense = 5
material(2).description = "tin": material(2).expense = 17.5
material(3).description = "copper": material(3).expense = 17.5
material(4).description = "iron": material(4).expense = 35
material(5).description = "silver": material(5).expense = 40
material(6).description = "coal": material(6).expense = 50
material(7).description = "gold": material(7).expense = 65
material(8).description = "mith": material(8).expense = 80
material(9).description = "adamantite": material(9).expense = 95
material(10).description = "rune": material(10).expense = 125
End Sub
private Sub cmdCalculate_Click()
Dim xp as Long
Dim lvl as Integer
Dim answer as Long
Dim matindex as Integer
Dim material as string
Dim title, message, buttons
Dim thismaterial as string
Dim I as Integer
thismaterial = Trim(txtMine.Text)
lvl = Val(txtLvl.Text)
xp = Val(txtXp.Text)
If lvl > 99 Or lvl < 1 then
title = "error :P Invalid option"
message = "Please Enter A Number From 1 to 99 for the lvl you wish to reach!"
buttons = vbOKOnly
Call MsgBox(message, buttons, title)
lblAnswer.Caption = ""
lblanswer2.Caption = ""
else
matindex = 0
for I = 1 to 99
If thismaterial = material(I).description then
matindex = I: Exit for
End If
If matindex = 0 then
title = "error :P Invalid option"
message = "Please Enter either : clay, tin, copper, iron, silver, coal, gold, mith, adamantite or rune!"
buttons = vbOKOnly
Call MsgBox(message, buttons, title)
lblAnswer.Caption = ""
lblanswer2.Caption = ""
End If
answer = (LevelXp(lvl) - xp) / material(matindex).expense
lblAnswer.Caption = answer
lblanswer2.Caption = Trim(txtMine.Text)
End Sub
private Sub cmdExit_Click()
End
End Sub
private Sub Command1_Click()
txtMine.Text = ""
txtLvl.Text = ""
lblAnswer.Caption = ""
lblanswer2.Caption = ""
txtXp.Text = ""
End Sub
private Sub Form_Load()
initializemyarrays
End Sub
# 23 Re: Small Prob :(
Look at the 5th varaible declaration in your Sub_cmdCalculate_click. You declared the Material again as String. Replace that with other name because you have already declared Material as an array of MaterialType.
aio at 2007-11-10 0:56:02 >
