Free Resources from FMS

Additional Resources

 

Thank you! Thank you! I just finished reading this document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.

Darren D.

 

Free Catalog

 

Acquiring User's Radio Button Selection using VB.NET

Provided by: FMS Development Team

VB.Net Example

Imports System.Windows.Forms

Public
Class RadioButtonSelection
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()
        'This call is required by the Windows Form Designer.
        InitializeComponent()
        'Add any initialization after the InitializeComponent() call
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    Friend WithEvents gpbColors As System.Windows.Forms.GroupBox
    Friend WithEvents btnColorSelection As System.Windows.Forms.Button
    Friend WithEvents colorGreen As System.Windows.Forms.RadioButton
    Friend WithEvents colorBlue As System.Windows.Forms.RadioButton
    Friend WithEvents colorRed As System.Windows.Forms.RadioButton

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        Me.gpbColors = New System.Windows.Forms.GroupBox
        Me.colorGreen = New System.Windows.Forms.RadioButton
        Me.colorBlue = New System.Windows.Forms.RadioButton
        Me.colorRed = New System.Windows.Forms.RadioButton
        Me.btnColorSelection = New System.Windows.Forms.Button
        Me.gpbColors.SuspendLayout()
        Me.SuspendLayout()

        'gpbColors
        Me.gpbColors.Controls.Add(Me.colorGreen)
        Me.gpbColors.Controls.Add(Me.colorBlue)
        Me.gpbColors.Controls.Add(Me.colorRed)
        Me.gpbColors.Location = New System.Drawing.Point(16, 16)
        Me.gpbColors.Name = "gpbColors"
        Me.gpbColors.Size = New System.Drawing.Size(144, 152)
        Me.gpbColors.TabIndex = 0
        Me.gpbColors.TabStop = False
        Me.gpbColors.Text = "Select a color"

        'colorGreen
        Me.colorGreen.BackColor = System.Drawing.SystemColors.Control
        Me.colorGreen.Location = New System.Drawing.Point(40, 112)
        Me.colorGreen.Name = "colorGreen"
        Me.colorGreen.Size = New System.Drawing.Size(56, 24)
        Me.colorGreen.TabIndex = 2"
        Me.colorGreen.Tag = "3"
        Me.colorGreen.Text = "Green"

        'colorBlue
        Me.colorBlue.BackColor = System.Drawing.SystemColors.Control
        Me.colorBlue.Location = New System.Drawing.Point(40, 68)
        Me.colorBlue.Name = "colorBlue"
        Me.colorBlue.Size = New System.Drawing.Size(56, 24)
        Me.colorBlue.TabIndex = 1
        Me.colorBlue.Tag = "2"
        Me.colorBlue.Text = "Blue"

        'colorRed
        Me.colorRed.BackColor = System.Drawing.SystemColors.Control
        Me.colorRed.Location = New System.Drawing.Point(40, 24)
        Me.colorRed.Name = "colorRed"
        Me.colorRed.Size = New System.Drawing.Size(56, 24)
        Me.colorRed.TabIndex = 0
        Me.colorRed.Tag = "1"
        Me.colorRed.Text = "Red"

        'btnColorSelection
        Me.btnColorSelection.Location = New System.Drawing.Point(16, 184)
        Me.btnColorSelection.Name = "btnColorSelection"
        Me.btnColorSelection.Size = New System.Drawing.Size(144, 24)
        Me.btnColorSelection.TabIndex = 1
        Me.btnColorSelection.Text = "Color Selection"

        'RadioButtonSelection
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(176, 222)
        Me.Controls.Add(Me.btnColorSelection)
        Me.Controls.Add(Me.gpbColors)
        Me.Name = "RadioButtonSelection"
        Me.Text = "Colors"
        Me.gpbColors.ResumeLayout(False)
        Me.ResumeLayout(False)
    End Sub
#End Region

    Public Enum ColorSelections
        Red = 1
        Blue = 2
        Green = 3
    End Enum

    Private mColorSelectedByInteger As Integer
    Private mColorSelectedByEnumeration As ColorSelections

    Private Sub btnColorSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles btnColorSelection.Click
        MessageBox.Show(mColorSelectedByInteger.ToString, "By Number")
        MessageBox.Show(mColorSelectedByEnumeration.ToString, "By Enumeration")
    End Sub

    Private Sub GetColorByNumber(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles colorRed.CheckedChanged, _
                colorBlue.CheckedChanged, _
                colorGreen.CheckedChanged
        mColorSelectedByInteger = CType(CType(sender, RadioButton).Tag, Integer)
    End Sub

    Private Sub GetColorByEnumeration(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles colorRed.CheckedChanged, _
                colorBlue.CheckedChanged, _
                colorGreen.CheckedChanged
        mColorSelectedByEnumeration = CType(CType(sender, RadioButton).Tag, ColorSelections)
    End Sub
End Class

Back to this tip's Main Page