Associate
- Joined
- 14 Oct 2009
- Posts
- 502
- Location
- Newport, Shropshire
Hi all,
Recently started computing and am building my own Army Building software for Warhammer 40k via Visual basic.
however i have run into an issue.
Basically i have the total of the army at the bottom, to add a unit to the army you press a button then select the unit, each unit is given a number, then you enter the quantity of the unit, then it displays the unit you have chosen in one text box and the points cost of that one unit on the other text box. The issue i have is that if you put in a unit in say Elite slot 1 which is say 280 points. And then change it to a different unit which costs say 280 points again the army total will be 560 points, rather than when you press the button to change the selection it resetting the points cost.
Dim Elite1 As Integer
Dim Elite1Qty As Integer
Dim Elite1Total As Integer
Elite1 = InputBox("Please Input your elites choice, 1 = Pariah, 2 = Flayed one and 3 = Immortal ")
If Elite1 = 1 Then
Elite1Qty = InputBox("Input the number of pariahs you want")
Elite1Total = (Elite1Qty * 36)
Elite1_txt.Text = ("Pariahs x " & Elite1Qty)
End If
If Elite1 = 2 Then
Elite1Qty = InputBox("Input the number of Flayed ones you want")
Elite1Total = (18 * Elite1Qty)
Elite1_txt.Text = ("Flayed ones x " & Elite1Qty)
End If
If Elite1 = 3 Then
Elite1Qty = InputBox("Input the number of Immortals you want")
Elite1Total = (28 * Elite1Qty)
Elite1_txt.Text = ("Immortals x " & Elite1Qty)
End If
If Elite1 replace Then
End If
Elite1Totaltxt.Text = Elite1Total
Army_total = Army_total + Elite1Total
Armytotaltxt.Text = Army_total
This is the piece of code. I am running the Army total at the end of all the IF statements should i run it inside each of the IF statements?
Or i was wondering if i could use an if statement which triggers when the button is pressed a second time, which then resets the value of Elite1Total, therefore not totalling up the points cost.
Sorry for the wall of text but im new to this all, this is my 4th week of the course And i know its an extremely basic piece of software but this is where im starting from so any help would be great!
Cheers
Recently started computing and am building my own Army Building software for Warhammer 40k via Visual basic.
however i have run into an issue.
Basically i have the total of the army at the bottom, to add a unit to the army you press a button then select the unit, each unit is given a number, then you enter the quantity of the unit, then it displays the unit you have chosen in one text box and the points cost of that one unit on the other text box. The issue i have is that if you put in a unit in say Elite slot 1 which is say 280 points. And then change it to a different unit which costs say 280 points again the army total will be 560 points, rather than when you press the button to change the selection it resetting the points cost.
Dim Elite1 As Integer
Dim Elite1Qty As Integer
Dim Elite1Total As Integer
Elite1 = InputBox("Please Input your elites choice, 1 = Pariah, 2 = Flayed one and 3 = Immortal ")
If Elite1 = 1 Then
Elite1Qty = InputBox("Input the number of pariahs you want")
Elite1Total = (Elite1Qty * 36)
Elite1_txt.Text = ("Pariahs x " & Elite1Qty)
End If
If Elite1 = 2 Then
Elite1Qty = InputBox("Input the number of Flayed ones you want")
Elite1Total = (18 * Elite1Qty)
Elite1_txt.Text = ("Flayed ones x " & Elite1Qty)
End If
If Elite1 = 3 Then
Elite1Qty = InputBox("Input the number of Immortals you want")
Elite1Total = (28 * Elite1Qty)
Elite1_txt.Text = ("Immortals x " & Elite1Qty)
End If
If Elite1 replace Then
End If
Elite1Totaltxt.Text = Elite1Total
Army_total = Army_total + Elite1Total
Armytotaltxt.Text = Army_total
This is the piece of code. I am running the Army total at the end of all the IF statements should i run it inside each of the IF statements?
Or i was wondering if i could use an if statement which triggers when the button is pressed a second time, which then resets the value of Elite1Total, therefore not totalling up the points cost.
Sorry for the wall of text but im new to this all, this is my 4th week of the course And i know its an extremely basic piece of software but this is where im starting from so any help would be great!
Cheers