Current location: Hot Scripts Forums » Programming Languages » Visual Basic » help with prog im a compete newb


help with prog im a compete newb

Reply
  #1 (permalink)  
Old 09-12-10, 03:40 PM
ieatkitties ieatkitties is offline
New Member
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb help with prog im a compete newb

okay I'm trying to create a small game in vb 2010 that will have the player and an enemy shows the health strength level and health but you press attack the computer rolls a dice if its below 10 its a miss if its ten or above its a hit then subtracts the value of strength and level from the enemy and hero's health i can get it do do everything up to removing the health it will remove and then change the health but wont permanently change the health so every time i press attack it just repeats the same number of 90 - 7 or 83instead of removing 7 from it changing it to 83 and then when i press it again subtracting 7 from 83
heres the code ,im 14 and ive learned the very basics of programing on visual basic and this is the first thing ive made myself
Public Class Form1

Code:
Public Class Form1

    Private Sub btnAttack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAttack.Click
        Dim Ehealth, herohealth, strength, level, armor, armorE, strengthE, levelE As Integer
        Ehealth = 50
        strength = 5
        level = 7
        armor = 8
        levelE = 4
        strengthE = 3
        armorE = 3
        herohealth = 90
        Dim attackh As Integer
        attackh = strength + level
        Dim attackE As Integer
        attackE = strengthE + levelE
        Randomize()
        Dim value As Integer = CInt(Int((20 * Rnd()) + 1))

        Dim hit As String
        hit = "hit"

        Dim miss As String
        miss = "miss"

        If value = (1) Then lstResults.Items.Add(miss)
        If value = (2) Then lstResults.Items.Add(miss)
        If value = (3) Then lstResults.Items.Add(miss)
        If value = (4) Then lstResults.Items.Add(miss)
        If value = (5) Then lstResults.Items.Add(miss)
        If value = (6) Then lstResults.Items.Add(miss)
        If value = (7) Then lstResults.Items.Add(miss)
        If value = (8) Then lstResults.Items.Add(miss)
        If value = (9) Then lstResults.Items.Add(miss)
        If value = (10) Then lstResults.Items.Add(hit)
        If value = (11) Then lstResults.Items.Add(hit)
        If value = (12) Then lstResults.Items.Add(hit)
        If value = (13) Then lstResults.Items.Add(hit)
        If value = (14) Then lstResults.Items.Add(hit)
        If value = (15) Then lstResults.Items.Add(hit)
        If value = (16) Then lstResults.Items.Add(hit)
        If value = (17) Then lstResults.Items.Add(hit)
        If value = (18) Then lstResults.Items.Add(hit)
        If value = (19) Then lstResults.Items.Add(hit)
        If value = (20) Then lstResults.Items.Add(hit)

        If hit Then Ehealth = Ehealth - 9
        If hit Then herohealth = herohealth - 3


        lstEnemiehealthandinfo.Items.Add(Ehealth)
        lstHeroinfo.Items.Add(herohealth)


    End Sub
    
    
End Class

Last edited by ieatkitties; 09-12-10 at 03:42 PM.
Reply With Quote
  #2 (permalink)  
Old 04-04-11, 10:37 AM
waterdamage waterdamage is offline
New Member
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Use a loop statement

research "loop". You should be able to shorten and steamline your code.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sending data from 1 prog to another kjarli C/C++ 2 05-20-08 11:40 AM
New to all of this. please help me fix this simple prog WomBat Windows .NET Programming 1 05-15-05 09:12 PM
hi im a newb leoneo11 New Members & Introductions 3 04-05-05 12:45 AM
Text bar JavaScript... Please help me find it! (Newb) msafi JavaScript 4 10-08-04 12:38 PM
Yoyoyoyo Newb Needs Help =] Xyo Script Requests 1 12-10-03 03:56 AM


All times are GMT -5. The time now is 01:19 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.