⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form2.vb

📁 vb 应用实例 简单应用 ddddddddddddddddddddddddddddddddd
💻 VB
字号:
Public Class Form2
    Inherits System.Windows.Forms.Form

#Region " Windows Form 设计工具产生的程序代码 "

    Public Sub New()
        MyBase.New()

        '此呼叫为 Windows Form 设计工具的必要项。
        InitializeComponent()

        '在 InitializeComponent() 呼叫之后加入所有的初始设定

    End Sub

    'Form 覆写 Dispose 以清除组件清单。
    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

    '为 Windows Form 设计工具的必要项
    Private components As System.ComponentModel.IContainer

    '注意: 以下为 Windows Form 设计工具所需的程序
    '您可以使用 Windows Form 设计工具进行修改。
    '请勿使用程序代码编辑器来修改这些程序。
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(195, 8)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(96, 24)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "取消"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(297, 8)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(96, 24)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "确定"
        '
        'Form2
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(399, 266)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1})
        Me.Name = "Form2"
        Me.Text = "Form2"
        Me.ResumeLayout(False)

    End Sub

#End Region
    Private m_Title As String
    Private m_From2Response As String

    Public ReadOnly Property From2Controls() As Control.ControlCollection
        Get
            Return Me.Controls
        End Get
    End Property

    Public Property From2Height() As Integer
        Get
            Return Me.Height
        End Get
        Set(ByVal Value As Integer)
            Me.Height = Value
        End Set
    End Property

    Public ReadOnly Property From2Response() As String
        Get
            Return m_From2Response
        End Get
    End Property

    Public Property From2Title() As String
        Get
            Return m_Title
        End Get
        Set(ByVal Value As String)
            m_Title = Value
            Me.Text = m_Title
        End Set
    End Property

    Public Property From2Width() As Integer
        Get
            Return Me.Width
        End Get
        Set(ByVal Value As Integer)
            Me.Width = Value
        End Set
    End Property

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        m_From2Response = "hello dws"
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        '显示调查结果
        Dim myControl As Control
        Dim myGroupControl As Control
        Dim myGroupBox As GroupBox
        Dim myObject As Object
        Dim myRadio As RadioButton

        Me.m_From2Response = ""

        For Each myControl In Me.Controls
            Select Case TypeName(myControl)
                Case "ComboBox"
                    m_From2Response += myControl.Name + " : "
                    m_From2Response += myControl.Text
                    m_From2Response += vbCrLf
                Case "TextBox"
                    m_From2Response += myControl.Name + " : "
                    m_From2Response += myControl.Text
                    m_From2Response += vbCrLf
                Case "GroupBox"
                    For Each myGroupControl In CType(myControl, GroupBox).Controls
                        If TypeOf myGroupControl Is RadioButton Then
                            If CType(myGroupControl, RadioButton).Checked Then
                                m_From2Response += myControl.Name + " : "
                                m_From2Response += myGroupControl.Text
                                m_From2Response += vbCrLf
                            End If
                        End If

                    Next
                Case "ListBox"
                    m_From2Response += myControl.Name + " : "
                    For Each myObject In CType(myControl, ListBox).SelectedItems
                        If TypeOf myObject Is String Then
                            m_From2Response += vbCrLf + CStr(myObject)
                        End If
                    Next
                    m_From2Response += vbCrLf
            End Select
        Next

        Me.Close()
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -