VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2496
   ClientLeft      =   48
   ClientTop       =   336
   ClientWidth     =   3744
   LinkTopic       =   "Form1"
   ScaleHeight     =   2496
   ScaleWidth      =   3744
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox txtDisplay 
      Height          =   288
      Left            =   240
      TabIndex        =   4
      Top             =   1920
      Width           =   2292
   End
   Begin VB.CommandButton cmdOption 
      Caption         =   "Select an option"
      Height          =   372
      Left            =   240
      TabIndex        =   3
      Top             =   1440
      Width           =   2292
   End
   Begin VB.OptionButton optDisplay 
      Caption         =   "Display text from Combo box"
      Height          =   372
      Left            =   240
      TabIndex        =   2
      Top             =   1080
      Width           =   2292
   End
   Begin VB.OptionButton optAdd 
      Caption         =   "Add Text to Combo box"
      Height          =   372
      Left            =   240
      TabIndex        =   1
      Top             =   720
      Width           =   2172
   End
   Begin VB.ComboBox Combo1 
      Height          =   288
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   2292
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdOption_Click()
    '   Use the button caption to determine
    '   how your code is going to act
    Select Case cmdOption.Caption
        Case "Add text"
            '   Make sure there is some text
            '   to add. Add it to the combo box
            '   Set the current value of the combo
            '   to what you just added and clear
            '   the text box
            If txtDisplay.Text <> "" Then
                Combo1.AddItem txtDisplay.Text
                Combo1.Text = txtDisplay.Text
                txtDisplay.Text = ""
            End If
        Case "Display text"
            '   Make sure an item is selected to display
            If Combo1.Text = "" Then
                MsgBox "Select an item from the combo box"
            Else
                '   Display the item in a text box
                txtDisplay.Text = Combo1.Text
            End If
        Case Else
            '   Make sure an option button has been selected
            MsgBox "Please select and option"
    End Select
End Sub

Private Sub Form_Load()
    '   Load a few items to start with
    Combo1.AddItem "Hello"
    Combo1.AddItem "Bye"
End Sub

Private Sub optAdd_Click()
    cmdOption.Caption = "Add text"
    txtDisplay.Text = ""
    txtDisplay.SetFocus
End Sub

Private Sub optDisplay_Click()
    cmdOption.Caption = "Display text"
End Sub
