Results 1 to 6 of 6

Thread: Active-X control question.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Melbourne
    Posts
    7

    Question

    Hi. I'm creating trying to create an Active-X control for one of my projects. The purpose of the control is to place a combobox on the form, and allow the user to select from a list of states within Australia. However, it is not really working properly. While the values in the combobox show up just fine and can be selected, I can't seem to grab the selected value out of the control itself. Can someone please help? TIA. The coding is shown below.


    Option Explicit

    Public Event Click()
    Public Event Change()

    Private Sub cboState_Change()
    RaiseEvent Change
    End Sub

    Private Sub cboState_Click()
    RaiseEvent Click
    End Sub

    Private Sub UserControl_Initialize()
    With cboState
    .AddItem ("N/A") 'Not Applicable
    .AddItem ("NSW") 'New South Wales
    .AddItem ("NT") 'Northern Territory
    .AddItem ("QLD") 'Queensland
    .AddItem ("SA") 'Southern Australia
    .AddItem ("TAS") 'Tasmania
    .AddItem ("VIC") 'Victoria
    .AddItem ("WA") 'Western Australia
    End With
    End Sub

    Public Property Get Text() As String
    Text = cboState.Text
    End Property

    Public Property Let Text(ByVal New_Text As String)
    PropertyChanged "Text"
    End Property

  2. #2
    Addicted Member Michel Jr's Avatar
    Join Date
    Jan 2000
    Location
    Brazil
    Posts
    175

    Smile Getting Activex Combo Text

    Hi,

    I think your problem is in the Text property set up.
    Try this:
    1- Start your VB Activex project.
    2-Go to Add-Ins menu and click Activex Control Interface Wizard.
    3- Click Next in the Introduction screen.
    4- Select Text in the left square and click > to move it to the right square. Click Next to go ahead.
    5- Click Next again to skip the Create Custom Interface Members
    6- In the Setting Map screen, select Text in the left square. In the 2 right rectangles (Maps to) select Control = Combo1 and Member = Text. Click Next to go ahead.
    7- In the Setting Attributes screen, click next again to go ahead.
    8- Then Finish.

    Now you can try to access the UserControl.Text property and get the current Combo text.


    I hope this can help you...

    Michel Jr.


  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Melbourne
    Posts
    7

    Thumbs up

    Yup. It did. Thanks.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Melbourne
    Posts
    7

    Unhappy Oops...

    Err...hang on. Nope, something is still wrong. I can get the text property now, but I still can't set it. They're telling me that its read only now.

    Option Explicit

    Private Sub UserControl_Initialize()
    With cboState
    .AddItem ("N/A") 'Not Applicable
    .AddItem ("NSW") 'New South Wales
    .AddItem ("NT") 'Northern Territory
    .AddItem ("QLD") 'Queensland
    .AddItem ("SA") 'Southern Australia
    .AddItem ("TAS") 'Tasmania
    .AddItem ("VIC") 'Victoria
    .AddItem ("WA") 'Western Australia
    End With
    End Sub

    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MappingInfo=cboState,cboState,-1,Text
    Public Property Get Text() As String
    Text = cboState.Text
    End Property

    Public Property Let Text(ByVal New_Text As String)
    cboState.Text() = New_Text
    PropertyChanged "Text"
    End Property

  5. #5
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    What is the style of the comboBox?

    If it is set to 2, then you will not be able to set the text, as the text is only read only in that scenario.
    Iain, thats with an i by the way!

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Melbourne
    Posts
    7

    Talking

    Oops. Silly me. I forgot I changed it to a Dropdown List.

    Dang, all this coding is getting to my head...

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