Fun code
Fun code
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: Fun code

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Las Vegas Nevada USA
    Posts
    239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Here's some code that will pop up multiple stars on a worksheet at one second intervals and then remove them.

    Public Sub ShowStars()
    Randomize
    StarWidth = 50
    StarHeight = 50
    For i = 1 To 100
    TopPos = Rnd() * (ActiveWindow.UsableHeight - StarHeight)
    LeftPos = Rnd() * (ActiveWindow.UsableWidth - StarWidth)
    Set NewStar = ActiveSheet.Shapes.AddShape _
    (msoShape4pointStar, LeftPos, TopPos, StarWidth, StarHeight)
    NewStar.Fill.ForeColor.SchemeColor = Int(Rnd() * 56)
    Delay 0.01
    DoEvents
    Next i

    Application.Wait Now + TimeValue("00:00:01")

    Set myShapes = Worksheets(1).Shapes
    For Each shp In myShapes
    If Left(shp.Name, 9) = "AutoShape" Then
    shp.Delete
    Delay 0.01
    End If
    Next

    End Sub


    Public Sub Delay(rTime As Single)
    'delay rTime seconds (min=.01, max=300)
    Dim oldTime As Variant
    'safety net
    If rTime < 0.01 Or rTime > 300 Then rTime = 1
    oldTime = Timer
    Do
    DoEvents
    Loop Until Timer - oldTime > rTime

    End Sub



    _________________
    George

    [ This Message was edited by: GeorgeB on 2002-04-02 21:24 ]

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Perth Australia
    Posts
    1,579
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi George
    That's cool man.
    Derek

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Las Vegas Nevada USA
    Posts
    239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Derek
    Glad you liked it. Pass it around down under.
    George
    George

    Learn to listen. Opportunity sometimes knocks very softly.

  4. #4
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi George. I like this code. It's Amazing....
    By the way I made a game using Cells.Interior.ColorIndex.
    it seems just like a snake is moving.

    ‚hthink you like the program which something moves on sheet.
    If you wish, I will mail it to you.

    Regards,

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    Las Vegas Nevada USA
    Posts
    239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Colo
    Thanks for the offer, however my employer takes a dim view of receiving downloads from sources unknown to upper mgmt. I would like to see the code. If you could post it for all to see I'm sure it will get a lot of attention.
    Thanx
    George
    George

    Learn to listen. Opportunity sometimes knocks very softly.

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Colo,

    I'd like to see the code.

  7. #7
    New Member
    Join Date
    Mar 2002
    Location
    Fresno, CA USA
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    This is pretty cool. Now how do you get it to run automatically when you open the workbook, or open a sheet within a workbook? Tom

  8. #8
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi all. I uploaded the file temporarily.
    You can download the file at following url.

    If you able to open zip format(68.0 KB)
    http://www.rui-taka.co.jp/ExcelSnakeWW.zip

    else (198 KB)
    http://www.rui-taka.co.jp/ExcelSnakeWW.xls


    I created this game, in order to study VBA.
    I want you to see the codes and please let me know your comment.

    With Regards,

    Colo (I'm called corosuke in Jpn).

  9. #9
    Board Regular
    Join Date
    Feb 2002
    Location
    Las Vegas Nevada USA
    Posts
    239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Tom
    Put the code in either a workbook or a worksheet on activate module.
    Same way you get any code to run on open.
    George
    George

    Learn to listen. Opportunity sometimes knocks very softly.

  10. #10
    Board Regular
    Join Date
    Feb 2002
    Posts
    177
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Hi George,
    Can you tell me how to run the code. I don't know how to even start the code. I'm pretty new to excel.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com