Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Radio button text variables?

iasghostiasghost Posts: 4Member
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 Posts: 85Member
    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 Posts: 4Member
    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 Posts: 33Member
    Check your naming! lol. It is now txtName I believe! lol. Check closer next time dude!


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


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



  • GazzaladGazzalad Posts: 85Member
    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.