|
-
Aug 25th, 2010, 07:13 PM
#1
Thread Starter
Junior Member
Adding Up Numbs
Im developing a Text based Rpg on VB and Im fair new at it but I need help with a code i need and I dont know how to code it.
Race Selector
Code:
Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
HealthStat.Text = 15
End Sub
Easily to see this code will add the number 15 in my Health Starter Stat but I need help with the second button which its my Class selector
Class Selector
Code:
Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
HealthStat.Text =
End Sub
At HealthStat.Text = I need a code that will add like a number to the current 15 in my Health Starter Stat textbox. so can anyone help me? This might be a easy code for anyone out there but i couldnt think on 1
-
Aug 25th, 2010, 07:39 PM
#2
Re: Adding Up Numbs

I've moved your thread to here which is the proper forum.
-
Aug 25th, 2010, 08:01 PM
#3
Thread Starter
Junior Member
-
Aug 25th, 2010, 08:01 PM
#4
Re: Adding Up Numbs
First up, as your health value is an integer, I would suggest that you declare a member variable of type Integer for it:
vb.net Code:
Private health As Integer
Whenever you want to change the health value, you use that Integer:
vb.net Code:
'Set the health to 15. Me.health = 15 'Add 10 to the current health. Me.health = Me.health + 10 'Add another 10 to the current health. Me.health += 10
Whenever you want to display the current health, you display the value of that variable, converting it to a String first:
vb.net Code:
HealthStat.Text = Me.health.ToString()
-
Aug 25th, 2010, 08:03 PM
#5
Thread Starter
Junior Member
Re: Adding Up Numbs
Alright, ty but I am confused on were to put the codes in and at?
-
Aug 25th, 2010, 08:33 PM
#6
Re: Adding Up Numbs
You put the code wherever you need to execute it. The code doesn't dictate where it goes. The required functionality does. I've shown you how to set the health. Where do you need to set the health? That's where you put that code. I've shown you how to add to the health. Where do you need to add to the health? That's where you put that code. I've shown you how to display the health. Where do you need to display the health? That's where you put that code. Obviously you'll need to display the health immediately after you change the health. As for the declaration of the member variable, there's only one place that that can go because there's only one place that you can declare members: inside the type definition but outside any member definition, which basically means inside the form but outside any methods.
-
Aug 25th, 2010, 08:38 PM
#7
Thread Starter
Junior Member
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
|