Ned halp with Visual Basic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SyntheticDarkness
    FFR Player
    • May 2005
    • 42

    #1

    Ned halp with Visual Basic

    Hah, I have no idea if I can put this here or not, but oh well~
    My teacher said I need to generate 6 random numbers in excel, with no repeats, and a timer between each number appearing. Excel has a Visual Basic thingy in it, which is basically what the macro's are. But anyway. I need someone to help me make the code to generate 6 random numbers, between 1-100, with no repeats, and a timer between each number appearing. I need the numbers to appear in cells A1 to A6. Anyone up to the job? ;3
    Last edited by SyntheticDarkness; 02-28-2008, 02:46 PM.
  • HighBuddha
    FFR Player
    • Nov 2006
    • 250

    #2
    Re: Ned halp with Visual Basic

    don't ask for people to do your homework for you also i think this is the wrong forum.
    edit: nvm i thought there was a code forum for some reason

    Comment

    • SyntheticDarkness
      FFR Player
      • May 2005
      • 42

      #3
      Re: Ned halp with Visual Basic

      Not homework, coursework. ^^
      And I've already tried whoring google for help, no luck.

      Comment

      • JKPolk
        tool
        • Aug 2003
        • 3737

        #4
        Re: Ned halp with Visual Basic

        You're an idiot.

        Comment

        • SyntheticDarkness
          FFR Player
          • May 2005
          • 42

          #5
          Re: Ned halp with Visual Basic

          That would generate repeats.

          Comment

          • JKPolk
            tool
            • Aug 2003
            • 3737

            #6
            Re: Ned halp with Visual Basic

            Then learn to do an if statement. I'm not doing the project for you, this is easy stuff. If you don't understand it, try asking your teacher for help. Like you're supposed to.

            Comment

            • SyntheticDarkness
              FFR Player
              • May 2005
              • 42

              #7
              Re: Ned halp with Visual Basic

              Lawl, I never asked you to do it, I asked for help. xD

              Comment

              • EDEdDNEdDYFaN
                FFR Veteran
                • May 2003
                • 2118

                #8
                Re: Ned halp with Visual Basic

                Originally posted by SyntheticDarkness
                Lawl, I never asked you to do it, I asked for help. xD
                He gave you a link that essentially tells you everything that you need to do. And considering you seem to be too lazy to think for yourself heres a clue (If the vb in excel is similar to normal vb)

                Code:
                If intX = intY or intZ or intEtc then
                   intX = int((100 - 1 + 1) * rnd ) + 1
                else
                   intX = intX
                end if
                Hopefully you'll be able to think of the solution from there, otherwise you need to start using the rest of your brain some more.

                Comment

                • SyntheticDarkness
                  FFR Player
                  • May 2005
                  • 42

                  #9
                  Re: Ned halp with Visual Basic

                  Oh right, see, that's helpful. ;o
                  Thanks. ^^
                  Last edited by SyntheticDarkness; 02-28-2008, 03:01 PM.

                  Comment

                  • SyntheticDarkness
                    FFR Player
                    • May 2005
                    • 42

                    #10
                    Re: Ned halp with Visual Basic

                    Done it. I made it generate 6 numbers between 1-6, with a 1 second delay between each, no duplicates. Also, ph34r my sloppy coding skillz. ;3

                    Sub Macro6()
                    Application.OnTime Now + TimeValue("00:00:01"), "Rand1"
                    Application.OnTime Now + TimeValue("00:00:02"), "Rand2"
                    Application.OnTime Now + TimeValue("00:00:03"), "Rand3"
                    Application.OnTime Now + TimeValue("00:00:04"), "Rand4"
                    Application.OnTime Now + TimeValue("00:00:05"), "Rand5"
                    Application.OnTime Now + TimeValue("00:00:06"), "Rand6"
                    Range("G6").Select
                    End Sub

                    Sub Rand1()
                    Range("F1").Select
                    ActiveCell.FormulaR1C1 = Int((StaticRnd() * 6) + 1)
                    End Sub

                    Sub Rand2()
                    Rand2:
                    Range("F2").Select
                    ActiveCell.FormulaR1C1 = Int((StaticRnd() * 6) + 1)
                    If Range("F2") = Range("F1") Then
                    GoTo Rand2
                    End If
                    End Sub

                    Sub Rand3()
                    Rand3:
                    Range("F3").Select
                    ActiveCell.FormulaR1C1 = Int((StaticRnd() * 6) + 1)
                    If Range("F3") = Range("F1") Or Range("F3") = Range("F2") Then
                    GoTo Rand3
                    End If
                    End Sub

                    Sub Rand4()
                    Rand4:
                    Range("F4").Select
                    ActiveCell.FormulaR1C1 = Int((StaticRnd() * 6) + 1)
                    If Range("F4") = Range("F1") Or Range("F4") = Range("F2") Or Range("F4") = Range("F3") Then
                    GoTo Rand4
                    End If
                    End Sub

                    Sub Rand5()
                    Rand5:
                    Range("F5").Select
                    ActiveCell.FormulaR1C1 = Int((StaticRnd() * 6) + 1)
                    If Range("F5") = Range("F1") Or Range("F5") = Range("F2") Or Range("F5") = Range("F3") Or Range("F5") = Range("F4") Then
                    GoTo Rand5
                    End If
                    End Sub

                    Sub Rand6()
                    Rand6:
                    Range("F6").Select
                    ActiveCell.FormulaR1C1 = Int((StaticRnd() * 6) + 1)
                    If Range("F6") = Range("F1") Or Range("F6") = Range("F2") Or Range("F6") = Range("F3") Or Range("F6") = Range("F4") Or Range("F6") = Range("F5") Then
                    GoTo Rand6
                    End If
                    End Sub
                    Last edited by SyntheticDarkness; 02-28-2008, 04:19 PM.

                    Comment

                    • All_That_Chaz
                      Supreme Dictator For Life
                      • Apr 2004
                      • 5874

                      #11
                      Re: Ned halp with Visual Basic

                      vb's so cute.
                      Back to "Back to Earth"
                      Originally posted by FoJaR
                      dammit chaz
                      Originally posted by FoJaR
                      god dammit chaz
                      Originally posted by MalReynolds
                      I bet when you live in a glass house, the temptation to throw stones is magnified strictly because you're not supposed to.

                      Comment

                      • Problems
                        FFR Player
                        • Apr 2005
                        • 513

                        #12
                        Re: Ned halp with Visual Basic

                        If you ever need any more help and can't find any PM me 'cause my dad has like 15+ years in vb (and a buttload of other comp language) experience, but I'm sure FFR would be more convenient.

                        Comment

                        • SyntheticDarkness
                          FFR Player
                          • May 2005
                          • 42

                          #13
                          Re: Ned halp with Visual Basic

                          Mmk, thanks.

                          Comment

                          • All_That_Chaz
                            Supreme Dictator For Life
                            • Apr 2004
                            • 5874

                            #14
                            Re: Ned halp with Visual Basic

                            Visual Basic isn't even going to be supported anymore starting like... now, so don't bother. Anyone teaching vb is out of their mind.
                            Back to "Back to Earth"
                            Originally posted by FoJaR
                            dammit chaz
                            Originally posted by FoJaR
                            god dammit chaz
                            Originally posted by MalReynolds
                            I bet when you live in a glass house, the temptation to throw stones is magnified strictly because you're not supposed to.

                            Comment

                            • Kekeb
                              davai
                              • Dec 2006
                              • 2765

                              #15
                              Re: Ned halp with Visual Basic

                              Originally posted by All_That_Chaz
                              Visual Basic isn't even going to be supported anymore starting like... now, so don't bother. Anyone teaching vb is out of their mind.
                              Welcome to poor high schools.

                              Comment

                              Working...