Results 1 to 8 of 8

Thread: A problem

  1. #1

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417

    Unhappy A problem

    Good evnin' layds and gents
    Tonight, I want to relieve myself from my incridibly boring question. However, it goes a little something like this:

    I am making a game, consisting of a man, and a dragon. I've declared 'Dragon' as an object with several properties, and a method called 'move' which I'm going to use with a timer. I also hav a regular module, just to keep me NOT confused. The only thing that makes this program unique is that you need to press a button in order to surprisingly be attacked by enemies. When you click the command button, an enemy appears, as a dragon, of course. But, my problem is...

    NB. Just watch out cause a lot of variables is written in norwegian...
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'This is inside the regular module
    Public Sub GenDrage() '(GenDrage=Generate Dragon)
    Dim Bkst(5) As String, Navn As String 'Bkst(short for 'Bokstaver', means letters(as in a, b or c, etc)

    Dim Drag As New Drage 'Drage is my Class Module

    Randomize 'Here, I will just give my animal a random name
    For I = 0 To 5
    Bkst(I) = Chr((Rnd * 25) + Asc("A"))
    Next I

    Navn = Bkst(0) & LCase(Bkst(1)) & LCase(Bkst(2)) & LCase(Bkst(3))_& LCase(Bkst(4)) & LCase(Bkst(5))

    Drag.Name = Navn
    frmBane.MonNavn.Caption = Drag.Name 'and here the naming bits end

    With Drag
    .Name = Navn
    .Pic1 = "\drageh1.gif" 'it's supposed to be an animation...
    .Pic2 = "\drageh2.gif"
    .StartPosL = 360
    .StartPosT = 360
    .Speed = 120
    .Speed = Int(Rnd * 5) + 1
    .DestL = 9840
    .DestT = 360
    End With
    Dim Monster1 As Image
    Set Monster1 = frmBane.Img
    With Monster1
    .Picture = LoadPicture(App.Path & Drag.Pic1)
    .Left = Drag.StartPosL
    .Top = Drag.StartPosT
    End With
    End Sub

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    I am making my 'Drag As New Drage' inside this sub, which means I can only use the variable 'Drag' within this procedure. However, It would be nice to be able to use that keyword in other subs...for example the Move Method I created...

    HOW DO I DO IT? How can I declare my variabled 'Drag' and be able to use it in all the procedures I want? Or at least some of them...Dim Drag As New Drage

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Code:
       Public Drag as New Drage
    That will allow everything to use it.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    You would also have to declare it outside of the subroutine or function.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417
    Im not allowed to use the public statement in those types of subroutines. That's what my problem is all about...

    If i'm writing (In a standard module, of course):

    Public Sub GenDrage()
    Public Drag As New Drage
    end sub

    Then Visual Basic sends me a compile error which states
    "Invalid attribute in Sub or Function"

    How do I use the statement outside the subs when I Won't allow it to work unless I click the button?

  5. #5
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    As per Sastraxi,

    It needs to be declared outside of the subroutine. At the top of the module before all the sub's and functions is normally best.
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  6. #6
    Junior Member Arkayne's Avatar
    Join Date
    Mar 2001
    Location
    Missouri
    Posts
    18

    Smile

    Hi. this has nothing to do with your question or programming, just something off-topic that caught my attention...

    ****
    NB. Just watch out cause a lot of variables is written in norwegian...
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'This is inside the regular module
    Public Sub GenDrage() '(GenDrage=Generate Dragon)
    Dim Bkst(5) As String, Navn As String 'Bkst(short for 'Bokstaver', means letters(as in a, b or c, etc)

    ****

    Considering the word 'Bokstaver' is Norwegian,
    and in that area, the ancient alphabet was runic in nature.
    Probably a coincidence, but one of the roots of the word seems to be stave, which is what runic letters consisted of...
    Reality is relative,
    Nothing is impossible,
    Caffiene is the only thing keeping me alive.

  7. #7

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417

    About the Norwegian

    First, I will ask again:

    I want my dragon to appear when I've clicked a commandbutton. If I want my code 'public drag as new drage' to be outside the subroutine, I will not be in the posession of the power to have control on whenever I create the dragon. He will automaticly be created when I begin my application. So again, is it possible to control the statements outside the subroutines with events like Click and DragMove, Etc...?

    And now, a letter to Arkayne, which states the true meaning of the word 'bokstaver' and at the same time teaches you all about norwegian language and history.

    Dear Arkayne

    If you want it sorted out, I'll sort it out. In ancient Norwegian times, the norwegians spoke what the English called 'old norse', which was a runic language as you say. However, Norway was occupied by the danish in a couple of centuries, which, of course, influenced the norwegian language. When Norway again was free, in 1814, we were not accually freed, we were given to the Sweedish, however, we had our own laws and gouvernment. I 1905, we were at last on our own without any influence by Danes nor Sweedish. In the 20th century, Norway's language has become a neverending debate, but you might say it's still somewhat alike danish.
    Nevertheless, Norwegian is a Germanic language and is easier to compare with German than with English. 'Bokstaver' is not a word which comes from staves nor anything alike it.
    if we rip the word apart, we'll get
    'bok' and 'staver'

    'Bok' is norwegian for 'Book'. That states itself. But just to remind you. 'Bok' is not taken from the English word 'Book'. It's taken from the German word 'Buch', that goes for the english word 'Book' too...

    'Staver' comes from 'stavelser' which is norwegian for the rythm in the language, where you put pressure, for instance in the word
    Window, you might clap your hands twice, one for 'Win', and one for 'Dow'. That word does only have two 'Stavelser'. You see? So it's more complicated than you would think....Anyways, how the Anglo-Saxons in ancient times invented the word 'letter' is a meaningless hole in my mind.
    From the rEaL iGoR

  8. #8
    Junior Member Arkayne's Avatar
    Join Date
    Mar 2001
    Location
    Missouri
    Posts
    18
    one thing you might be able to do is create the dragon within the module (declare it there i mean) and then put the code for filling in the dragon's variables within the command button. just add a property to your dragon, something like '.exists' as boolean, and in your command button, when you set the variables for the dragon, set the .exists property to true. after it dies, set it to false again.
    then all you have to do is create a sub or function to check whether or not the dragon exists that you can put in the rest of your code.
    that way if the dragon hasn't been 'created' yet, it will see that and your dragon won't be 'created' until you hit the command button.
    this works especially well if your basic dragon is defined using the Type statement in the module. (because then it's easier to add the '.exists' property.
    This usually works for me.

    anyways, back to the language thing...
    thanks for explaining that I am intrigued by the various aspects of languages and alphabets, and have even created my own for use in fantasy stories. i'm def. going to have to remember that.
    Reality is relative,
    Nothing is impossible,
    Caffiene is the only thing keeping me alive.

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