Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Radio button text variables?

iasghostiasghost Member Posts: 4
Is there a way to use radio boxes to change the value of a text or string to be used in a msgbox? I am using the following but I get a compile error saying an object is needed:

dim weapon as string
~~~~~~~~~~~~~~~~~~~~
Private Sub optrope_Click()
Set weapon = "gun"

what is wrong? it should work.
One time, in programming class, I stuck an external CD burner up my USP port....

Comments

  • GazzaladGazzalad Member Posts: 85
    Remove the SET command and just have weapon = gun

    Set is used to create an update query and changes values in fields in a specified table based on specified criteria. I dont think this is what you are tying to achieve here.

    Also depending on where your dim statement is, if the variable is needed by more than one sub you will need to change it to:

    Public weapon as string

    Always try to get into the habit or using a naming conventions to name your variables depending on the type you define them as. For example:

    dim strWeapon as string
    dim intCounter as integer

    It makes it so much easier to read the code.

    Hope this helps

    G


    : Is there a way to use radio boxes to change the value of a text or string to be used in a msgbox? I am using the following but I get a compile error saying an object is needed:
    :
    : dim weapon as string
    : ~~~~~~~~~~~~~~~~~~~~
    : Private Sub optrope_Click()
    : Set weapon = "gun"
    :
    : what is wrong? it should work.
    : One time, in programming class, I stuck an external CD burner up my USP port....
    :

  • iasghostiasghost Member Posts: 4
    It seems to work but when I hit the button to open the message box it gives me run time error '424' Object needed. I click debug and it highlights the following code:


    MsgBox text1.Text & "kills self with" & strweapon & "and" & strtypedeath & "and dies" & streffect, vbOKOnly, "Suicide-'O'-Matic"

    and ideas?
  • maysmays Member Posts: 33
    Check your naming! lol. It is now txtName I believe! lol. Check closer next time dude!


    Mays
  • maysmays Member Posts: 33
    You got it though right bubba? lol.


    Mays
    :-( - "Mommy...I got caught with my server down!"



  • GazzaladGazzalad Member Posts: 85
    Theres Nothing wrong with the structure of this statement, all I can think is that you have used a variable that has not been defined.

    Run the programme again and when this line is highlighted in yellow move your mouse over the variables. What you should see is a value for each variable appearing. If any don't show up anything, they have not been assigned.

    Hope this helps..


    G


    : It seems to work but when I hit the button to open the message box it gives me run time error '424' Object needed. I click debug and it highlights the following code:
    :
    :
    : MsgBox text1.Text & "kills self with" & strweapon & "and" & strtypedeath & "and dies" & streffect, vbOKOnly, "Suicide-'O'-Matic"
    :
    : and ideas?
    :

Sign In or Register to comment.