Announcement

Collapse
No announcement yet.

Need help on a Visual Basic programming problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help on a Visual Basic programming problem

    I just need to know how to set up this array within the program to allow 10 values to be entered then later be shown into separate labels as a largest and smallest value.

    The question reads.

    Largest/Smallest Array Values

    Create an application that lets the user enter 10 values into an array. The application should display the largest and smallest values stored in the array. Figure 8-45 shows an example of the application's form after all 10 values have been entered, with the largest and smallest values displayed.

    The form basically shows a large label box where your values will show up. Then two regular labels next to the boxed label that determines the largest and smallest values. There are four buttons, a clear, exit, Display Min & Max, and Input Values.

    I have the actual program layout already made and the initial buttons already declared, being the exit and clear buttons. I just need to know how to setup the array's for the other two buttons.

    If you can help it would be much appreciated.

    Thanks
    1:exquisite> nvm for jd, brb throwin my dog in the dumpster

    TWBR Media Specialists
    http://www.youtube.com/fieryfire3d
    ^^^^^SUBSCRIBE^^^^^

    TWLD Season 14 Champ

  • #2
    Here's a crappy image file I made of the actual programming layout.

    1:exquisite> nvm for jd, brb throwin my dog in the dumpster

    TWBR Media Specialists
    http://www.youtube.com/fieryfire3d
    ^^^^^SUBSCRIBE^^^^^

    TWLD Season 14 Champ

    Comment


    • #3
      Are you trying to get a 2d spaceship game to do your homework for you?
      USA WORLD CHAMPS

      Comment


      • #4
        I have worked on this type of problem before.
        I am not sure what exactly you know, so here are some questions:

        1
        Do you know how to run some code when [Input Values] is clicked?
        Do you know how to make an InputBox popup?
        Do you know how to read text from an InputBox?
        Do you know how to convert text into a list of numbers?
        Do you know how to put those numbers into an array?
        Do you know how to update the box Label with the array's values?

        2
        Do you know how to run some code when [Display Min/Max] is clicked?
        Do you know how to calculate the smallest + largest number in an array?
        Do you know how to update the min/max Labels with a number?
        Last edited by Nockm; 06-17-2010, 04:07 AM.

        Comment


        • #5
          Does visual basic have a sorting feature or do you have to code one in? Sorting 10 values isn't hard so it's easy either way.

          Comment


          • #6
            Can I see what code you have so far? No point in starting from scratch.

            -24
            Help Promote TrenchWars - www.trenchwars.org/donations - www.trenchwars.org/donationsoverview

            Comment


            • #7
              Public Class Form1

              Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

              Me.Close()

              End Sub

              Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

              lblOne.Text = String.Empty
              Label3.Text = String.Empty
              Label4.Text = String.Empty

              End Sub


              Private Sub btnInput_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnInput.Click

              Dim strInput As String
              Dim intValues(9) As Integer


              Do
              strInput = InputBox("Enter 10 values (comma separated) in the field below:")
              If strInput = "" Then Exit Sub
              Dim stringvalues() As String = strInput.Split(New Char() {","c}, StringSplitOptions.RemoveEmptyEntries)

              If stringvalues.Length <> 10 Then
              MsgBox("Enter exactly 10 numbers.")
              Continue Do
              End If

              For x As Integer = 0 To stringvalues.Length - 1
              If Not Integer.TryParse(stringvalues(x), intValues(x)) Then
              MsgBox("Enter valid integer numbers.")
              Continue Do
              End If
              Next
              Exit Do
              Loop

              Label3.Text = intValues.Max.ToString
              Label4.Text = intValues.Min.ToString

              End Sub

              Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click

              ' I'll finish this part up later.

              End Sub
              End Class
              1:exquisite> nvm for jd, brb throwin my dog in the dumpster

              TWBR Media Specialists
              http://www.youtube.com/fieryfire3d
              ^^^^^SUBSCRIBE^^^^^

              TWLD Season 14 Champ

              Comment


              • #8
                It's rather easy, but I am not helping you with your homework...
                However if this is for anything but your homework, please tell me what it's for, and I might help you...
                TWLM-J Champion Season 8 :wub:
                TWLM-D Champion Season 9 <_<
                TWLM-B Champion Season 10 :pirate2:
                First person to win all different TWLM'ers :greedy:

                Comment


                • #9
                  =sum(A5:A24)
                  can we please have a moment for silence for those who died from black on black violence

                  Comment


                  • #10
                    Lol you assholes acting like you've never asked for help before. I can't remember exactly stylez but I still have my book from when I took this, I'll try to refresh my memory
                    JAMAL> didn't think there was a worse shark than midoent but the_paul takes it



                    turban> claus is the type of person that would eat shit just so you would have to smell his breath

                    Originally posted by Ilya;n1135707
                    the_paul: the worst guy, needs to go back to school, bad at his job, guido

                    Comment


                    • #11
                      The semesters already over with, I graduated! Woot!

                      Anyways, I just needed to turn this in for extra credit for an exam. Though, I aced the exam so I didn't really need this.

                      Thanks for the help guys! :wub:

                      P.s. My O.C.D. will probably allow me to work on this some more later, so if you wanna help spice this program up with me, by all means, go for it.
                      1:exquisite> nvm for jd, brb throwin my dog in the dumpster

                      TWBR Media Specialists
                      http://www.youtube.com/fieryfire3d
                      ^^^^^SUBSCRIBE^^^^^

                      TWLD Season 14 Champ

                      Comment


                      • #12
                        Public Function MaxValOfIntArray(ByRef TheArray As Variant) As Integer
                        'This function gives max value of int array without sorting an array
                        Dim i As Integer
                        Dim MaxIntegersIndex As Integer
                        MaxIntegersIndex = 0

                        For i = 1 To UBound(TheArray)
                        If TheArray(i) > TheArray(MaxIntegersIndex) Then
                        MaxIntegersIndex = i
                        End If
                        Next
                        'index of max value is MaxValOfIntArray
                        MaxValOfIntArray = TheArray(MaxIntegersIndex)
                        End Function
                        TW Web Developer

                        4:vys> yo
                        4:vys> 1 day ill be staff
                        4:vys> know it for sure
                        4:vys> yo P_L already told me that i'd be ZH one day when deluge is sys op and method owns TW

                        2:money> zazu got zizu'd when he should have zizzo'd

                        3:Lizard Fuel <ER>> !tell stop meeting girlfriends on subspace, who are you, hurricane?
                        3:RoboHelp> Told moth about stop meeting girlfriends on subspace, who are you, hurricane?
                        3:Lizard Fuel <ER>> oh sht

                        Comment


                        • #13
                          programming sucks

                          learned enough to get through my matlab and mechatronics classes

                          screw that

                          though matlab was ok since that was actually useful.


                          1996 Minnesota State Pooping Champion

                          Comment


                          • #14
                            Originally posted by Stylez View Post
                            P.s. My O.C.D. will probably allow me to work on this some more later, so if you wanna help spice this program up for me, by all means, go for it.
                            Fixed!

                            Comment


                            • #15
                              No real programmers work in VB

                              AFK

                              Cocoa, Java, Ruby on Rails, and C# for win ttyl

                              Comment

                              Working...
                              X