ComboBox test display

Discussion in 'AutoCAD' started by John Coon, Aug 23, 2003.

  1. John Coon

    John Coon Guest

    I'm trying to have a value placed in a TextBox based on a selection from a
    ComboBox.
    If I run debug the value I want placed in the TextBox appear in the flyout
    as being correct
    based on the selection, But only the 12" value is displaced in the form IN
    the TextBox.

    Thank you in advance


    Public Sub ComboBox1_Change()
    Dim strapprtype As String
    strapprtype = ComboBox1.Text
    Dim Precision As String
    Dim NonPrecision As String
    Dim Visual As String
    strapprtype = ComboBox1.Text
    If ComboBox1.Text = "Precision" Then
    strapprtype = Precision
    ElseIf ComboBox1.Text = "NonPrecision" Then
    strapprtype = NonPrecision
    Else
    strapprtype = Visual
    End If
    Dim strrwwidth As String
    If ComboBox1.Text = "Precision" Then
    strrwwidth = "36"""
    ElseIf ComboBox1.Text = "NonPrecision" Then
    strrwwidth = "18"""
    Else
    ComboBox1.Text = "Visual"
    strrwwidth = "12"""
    TextBox1.Text = strrwidth
    UserForm1.TextBox1 = strrwwidth
    End If
    End Sub

    Private Sub TextBox1_Change()

    End Sub

    Private Sub UserForm_Initialize()
    'block names for approachs to be inserted at
    'station offset and elevation supplied by
    'user
    UserForm1.ComboBox1.AddItem "Precision"
    UserForm1.ComboBox1.AddItem "NonPrecision"
    UserForm1.ComboBox1.AddItem "Visual"
    Dim strrwwidth As String
    UserForm1.TextBox1 = strrwwidth
    End Sub
     
    John Coon, Aug 23, 2003
    #1
  2. John Coon

    joesu Guest

    John,

    Here is your code fixed-up. HTH -- Joe

    Public Sub ComboBox1_Change()   With ComboBox1     Select Case .Text       Case "Precision"         TextBox1.Text = "36"""

    Case "NonPrecision"         TextBox1.Text = "18"""

    Case "Visual"         TextBox1.Text = "12"""     End Select   End With End Sub

    Private Sub UserForm_Initialize()   'block names for approachs to be inserted at   'station offset and elevation supplied by user   With ComboBox1     .AddItem "Precision"     .AddItem "NonPrecision"     .AddItem "Visual"   End With End Sub
     
    joesu, Aug 25, 2003
    #2
  3. John Coon

    John Coon Guest

    Joe,



    Thanks!!!! That is much shorter than my attempt. I thought about using case



    at first but the If Else command looked like it should of worked. Is there a



    reason why this type of method would not work for this type of test in a comboBox



    to a textBox or was it that I just had butchered it.



    I'm new to vba is why I ask.



     



     Thank you for your time.



    John Coon







     



     



     



     



    "joesu" <> wrote in message news:...

    John,

    Here is your code fixed-up. HTH -- Joe

    Public Sub ComboBox1_Change()   With ComboBox1     Select Case .Text       Case "Precision"         TextBox1.Text = "36"""

    Case "NonPrecision"         TextBox1.Text = "18"""

    Case "Visual"         TextBox1.Text = "12"""     End Select   End With End Sub

    Private Sub UserForm_Initialize()   'block names for approachs to be inserted at   'station offset and elevation supplied by user   With ComboBox1     .AddItem "Precision"     .AddItem "NonPrecision"     .AddItem "Visual"   End With End Sub
     
    John Coon, Aug 25, 2003
    #3
  4. John Coon

    joesu Guest

    John,

    Honestly, I think you just butcher it. I don't know of any reason why it would not work but I didn't try it that way.

    However, my rule of thumb is if I have more than 1 condition I'm testing for I find it easier to use a Select Case construct.

    Beginner? Cool, be sure to check out my latest book from Apress. I'm hoping it will be on bookselves sometime this Fall. It's currently in Tech Review.

    Joe
    --
     
    joesu, Aug 25, 2003
    #4
  5. John Coon

    John Coon Guest

    Joe,



     



    Thanks for your help.



    I look for your book it can only help.



     



    John Coon



    "joesu" <> wrote in message news:...

    John,

    Honestly, I think you just butcher it. I don't know of any reason why it would not work but I didn't try it that way.

    However, my rule of thumb is if I have more than 1 condition I'm testing for I find it easier to use a Select Case construct.

    Beginner? Cool, be sure to check out my latest book from Apress. I'm hoping it will be on bookselves sometime this Fall. It's currently in Tech Review.

    Joe
    --
     
    John Coon, Aug 26, 2003
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.