Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. arrays

arrays

Scheduled Pinned Locked Moved Visual Basic
data-structuresquestion
15 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    For a public function for batting averages would this be right? Dim outcome(10) As String 'declaring an array outcome(0) = "single" outcome(1) = "double" outcome(2) = "triple" outcome(3) = "home run" outcome(4) = "strike" outcome(5) = "ground out" outcome(6) = "fly out" outcome(7) = "walk" outcome(8) = "sacrifice bunt" outcome(9) = "sacrifice fly" outcome(10) = "hit by pitch" 'Step through the array and add the values For i = 0 To strPlateAppearance.Length - 1 total += strPlateAppearance(i) Next 'Divide by the number of elements in the array 'Assing the result of the Function Name and it will become the 'returned' value CalculateBattingAverage = total / strPlateAppearance.Length

    W C 2 Replies Last reply
    0
    • A Anonymous

      For a public function for batting averages would this be right? Dim outcome(10) As String 'declaring an array outcome(0) = "single" outcome(1) = "double" outcome(2) = "triple" outcome(3) = "home run" outcome(4) = "strike" outcome(5) = "ground out" outcome(6) = "fly out" outcome(7) = "walk" outcome(8) = "sacrifice bunt" outcome(9) = "sacrifice fly" outcome(10) = "hit by pitch" 'Step through the array and add the values For i = 0 To strPlateAppearance.Length - 1 total += strPlateAppearance(i) Next 'Divide by the number of elements in the array 'Assing the result of the Function Name and it will become the 'returned' value CalculateBattingAverage = total / strPlateAppearance.Length

      W Offline
      W Offline
      WartHog000
      wrote on last edited by
      #2

      hey, So you want to figure out a batting average of a player? i am not good with baseball averaging i just watch it ...... Wat does a single,a double etc.... equal? (how many points?) and are u doing a window Form or a console form???

      A C 2 Replies Last reply
      0
      • W WartHog000

        hey, So you want to figure out a batting average of a player? i am not good with baseball averaging i just watch it ...... Wat does a single,a double etc.... equal? (how many points?) and are u doing a window Form or a console form???

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        yeah i'm not too good at averaging either just watching....but im trying I set it up like this single = hit double = hit triple = hit home run = hit stike = miss ground out = miss fly out = miss walk = n/a sacrifice bunt = n/a sacrifice fly = n/a hit by pitch = n/a Then I put it If "hit" then inthits +1 intatbats +1 n/a the same and miss the same all toogether its inthits/intatbats while intNA = 0 then no offical atbats with an average of 0 still

        W 1 Reply Last reply
        0
        • A Anonymous

          For a public function for batting averages would this be right? Dim outcome(10) As String 'declaring an array outcome(0) = "single" outcome(1) = "double" outcome(2) = "triple" outcome(3) = "home run" outcome(4) = "strike" outcome(5) = "ground out" outcome(6) = "fly out" outcome(7) = "walk" outcome(8) = "sacrifice bunt" outcome(9) = "sacrifice fly" outcome(10) = "hit by pitch" 'Step through the array and add the values For i = 0 To strPlateAppearance.Length - 1 total += strPlateAppearance(i) Next 'Divide by the number of elements in the array 'Assing the result of the Function Name and it will become the 'returned' value CalculateBattingAverage = total / strPlateAppearance.Length

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          First, I know nothing of any games that have a batting average, you should assume that people don't know this. I am assuming you are talking about baseball, but I don't know the game. Anonymous wrote: 'Step through the array and add the values For i = 0 To strPlateAppearance.Length - 1 total += strPlateAppearance(i) Next 'Divide by the number of elements in You don't say what strPlateAppearance is? Where is outcome in the calculation? Where does total come from? You really need to provide all the relevant code.


          Do you want to know more? WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums

          A 1 Reply Last reply
          0
          • W WartHog000

            hey, So you want to figure out a batting average of a player? i am not good with baseball averaging i just watch it ...... Wat does a single,a double etc.... equal? (how many points?) and are u doing a window Form or a console form???

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            WartHog000 wrote: and are u doing a window Form or a console form??? Does that matter? It is an algorithm problem, not a GUI problem.


            Do you want to know more? WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums

            1 Reply Last reply
            0
            • A Anonymous

              yeah i'm not too good at averaging either just watching....but im trying I set it up like this single = hit double = hit triple = hit home run = hit stike = miss ground out = miss fly out = miss walk = n/a sacrifice bunt = n/a sacrifice fly = n/a hit by pitch = n/a Then I put it If "hit" then inthits +1 intatbats +1 n/a the same and miss the same all toogether its inthits/intatbats while intNA = 0 then no offical atbats with an average of 0 still

              W Offline
              W Offline
              WartHog000
              wrote on last edited by
              #6

              okay I think i got what you are saying. You can start a Window Form...New->Project->vb->WindowApplication i can show you how to make this program with a window form care to see?

              A 1 Reply Last reply
              0
              • W WartHog000

                okay I think i got what you are saying. You can start a Window Form...New->Project->vb->WindowApplication i can show you how to make this program with a window form care to see?

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                absolutely...I'm so stuck it's ridiculous. I started with the window form having the user enter the data into a textbox but after that I was stuck

                W 2 Replies Last reply
                0
                • A Anonymous

                  absolutely...I'm so stuck it's ridiculous. I started with the window form having the user enter the data into a textbox but after that I was stuck

                  W Offline
                  W Offline
                  WartHog000
                  wrote on last edited by
                  #8

                  okay i will make it....and send you the code for it.

                  1 Reply Last reply
                  0
                  • A Anonymous

                    absolutely...I'm so stuck it's ridiculous. I started with the window form having the user enter the data into a textbox but after that I was stuck

                    W Offline
                    W Offline
                    WartHog000
                    wrote on last edited by
                    #9

                    is this a game? or a caulation....because i am coding the caculation program

                    A 1 Reply Last reply
                    0
                    • W WartHog000

                      is this a game? or a caulation....because i am coding the caculation program

                      A Offline
                      A Offline
                      Anonymous
                      wrote on last edited by
                      #10

                      its a calculation program... actually do you think a select case statement would be better or the array?

                      W 1 Reply Last reply
                      0
                      • A Anonymous

                        its a calculation program... actually do you think a select case statement would be better or the array?

                        W Offline
                        W Offline
                        WartHog000
                        wrote on last edited by
                        #11

                        array all the way well i was thinking u have a textbox then when u click the button it will add the integer(number) to a listbox and to a arrayLIST (list is important)..the we will have a caculating button....and it will take all in the array list and average it out. do u have aol aim or msn address? it will be easier to explain then back and forth on a form.

                        A 1 Reply Last reply
                        0
                        • C Colin Angus Mackay

                          First, I know nothing of any games that have a batting average, you should assume that people don't know this. I am assuming you are talking about baseball, but I don't know the game. Anonymous wrote: 'Step through the array and add the values For i = 0 To strPlateAppearance.Length - 1 total += strPlateAppearance(i) Next 'Divide by the number of elements in You don't say what strPlateAppearance is? Where is outcome in the calculation? Where does total come from? You really need to provide all the relevant code.


                          Do you want to know more? WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums

                          A Offline
                          A Offline
                          Anonymous
                          wrote on last edited by
                          #12

                          that's true...I didn't provide that and I shouldn't assume everyone knows baseball either. Plate appearance will have an impact on batting average either hit, miss or n/a in example a test case of "single" double" "strike out" the function should return 2/3 = .666 and "walk" "double" and "stike out" it should return 1/2 = .5 basically a user interface that ties everything together A function and form module

                          W 1 Reply Last reply
                          0
                          • A Anonymous

                            that's true...I didn't provide that and I shouldn't assume everyone knows baseball either. Plate appearance will have an impact on batting average either hit, miss or n/a in example a test case of "single" double" "strike out" the function should return 2/3 = .666 and "walk" "double" and "stike out" it should return 1/2 = .5 basically a user interface that ties everything together A function and form module

                            W Offline
                            W Offline
                            WartHog000
                            wrote on last edited by
                            #13

                            ouch lol ...so a triple and a homerun and a strike out will equal somethin else lol

                            1 Reply Last reply
                            0
                            • W WartHog000

                              array all the way well i was thinking u have a textbox then when u click the button it will add the integer(number) to a listbox and to a arrayLIST (list is important)..the we will have a caculating button....and it will take all in the array list and average it out. do u have aol aim or msn address? it will be easier to explain then back and forth on a form.

                              A Offline
                              A Offline
                              Anonymous
                              wrote on last edited by
                              #14

                              ok owenguy22 on aol or aim

                              W 1 Reply Last reply
                              0
                              • A Anonymous

                                ok owenguy22 on aol or aim

                                W Offline
                                W Offline
                                WartHog000
                                wrote on last edited by
                                #15

                                kk chat there

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups