Results 1 to 6 of 6

Thread: [RESOLVED] dead or alive state help needed

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Resolved [RESOLVED] dead or alive state help needed

    hey im having a little trouble ,i have five blue tanks on the form and ive tried
    to setup a dead or alive .state .im missing something because i keep getting errors .methed or data member not found on .state part .its probly simple
    but i cant see it
    thanks


    Code:
    Option Explicit
    
    
    Private Enum bouncedir
    upLeft = 1
    upright = 2
    downLeft = 3
    downright = 4
    up = 5
    down = 6
    Left = 7
    Right = 8
    
    End Enum
    
    Private Const ALIVE        As Integer = 10
    Private Const DEAD         As Integer = 20
    Private Const max_tanks    As Integer = 5
    
    Private Const MAX_DISTANCE = 200
    Dim Running As Boolean
    Public state               As Integer
    Private xdir(0) As bouncedir  '~~~~ using an array
    Private ydir(0) As bouncedir  '~~~~ using an array
    
    Sub Inittanks()
        ' init variables for start-up
        Dim i As Integer
            
       
        
        For i = 0 To max_tanks
        
          
          With blue(i)
            
            .state = ALIVE
          End With
        Next i
        
    End Sub
    Attached Files Attached Files
    Last edited by flyhigh; Aug 12th, 2010 at 12:23 PM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: dead or alive state help needed

    Couple things.
    1) zip doesn't seem to include the .frm file
    2) I don't see where you declared Blue() or what data type it is
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: dead or alive state help needed

    hey im sorry i fixed zip file ,2) I don't see where you declared Blue() or what data type it is
    thats where i keep getting problems

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: dead or alive state help needed

    Quote Originally Posted by flyhigh View Post
    ...I don't see where you declared Blue() or what data type it is
    thats where i keep getting problems
    Of course. You have to declare Blue() as something. Do you have a class or user-defined type (UDT) that Blue is suppose to be? If so, you are missing:
    Dim Blue(0 To max_Tanks) As whateverBlueIs
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: dead or alive state help needed

    i get this error =member already exists in a object module from which this object module derives.
    blue(0) is number 1 tank image


    Code:
    Option Explicit
    
    
    Private Enum bouncedir
    upLeft = 1
    upright = 2
    downLeft = 3
    downright = 4
    up = 5
    down = 6
    Left = 7
    Right = 8
    
    End Enum
    
    Private Const ALIVE        As Integer = 10
    Private Const DEAD         As Integer = 20
    Private Const max_tanks    As Integer = 5
    
    Private Const MAX_DISTANCE = 200
    Dim Running As Boolean
    
    Private xdir(0) As bouncedir  '~~~~ using an array
    Private ydir(0) As bouncedir  '~~~~ using an array
    Dim blue(0 To 4)      As tanks
    Private Type tanks
       
       State As Integer
    End Type
    Sub Inittanks()
        ' init variables for start-up
        Dim i As Integer
            
       
        
        For i = 0 To max_tanks
        
          
          With blue(i)
            
            .State = ALIVE
          End With
        Next i
        
    End Sub
    
    
    
    
    Sub Run()
       
        While Running
    
    
    
    
    
    
    
    
    
    
            DoEvents
        Wend
    End Sub
    
    
    
    
    
    
    
    
    
    
    
    
     Private Sub start_Click()
    
    start.Enabled = False
    start.Visible = False
    Inittanks
    Running = True
        Run
         
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Running = False
    End Sub
    
    
    
    
    Private Sub Form_Load()
    
    
    Randomize
    
    
     
       
       
       Dim X As Integer
         X = (Int(Rnd * 8) + 1) 'Start in a random direction
         xdir(0) = X
        
       
       
       Dim Y As Integer
         Y = (Int(Rnd * 8) + 1) 'Start in a random direction
         ydir(0) = Y
     
      
         
     
      
    End Sub

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: dead or alive state help needed

    I haven't had time to try your project, but in the mean time look at these possible problems.

    1. I don't know if ALIVE or DEAD is also a property name of something in your project. You may want to try renaming them to something else like, maybe, STATE_ALIVE or STATE_DEAD?

    2. Look out for your enums. Left is a VB property & that might be causing the problems.
    Suggest renaming those enum members too, maybe: dir_Right, dir_Up, dir_Left, etc, etc
    Last edited by LaVolpe; Aug 12th, 2010 at 02:43 PM. Reason: typos
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

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



Click Here to Expand Forum to Full Width