Link 要在 vb 中的另一个表单上标记的变量

Link Variable to Label on another form in vb

我有一些大学课程作业的小程序,我必须输入一组人的性别和年龄数据,然后计算出男性和女性的百分比以及儿童和成人的百分比。我坚持的一点是我想在单独表格的标签上显示我的结果。这是我的代码:

Public Class Form1

Dim TotalGender As Integer
Dim TotalAge As Integer
Dim MaleCount As Integer
Dim FemaleCount As Integer
Dim ChildCount As Integer
Dim AdultCount As Integer
Dim MalePercent As Single
Dim FemalePercent As Single
Dim AdultPercent As Single
Dim ChildPercent As Single

Private Sub btnSub_Click(sender As Object, e As EventArgs) Handles btnSub.Click

    If cmbGender.Text = "Male" Then
        MaleCount += 1

    End If

    If cmbGender.Text = "Female" Then
        FemaleCount += 1

    End If

    If cmbAge.Text > 18 Then
        ChildCount += 1

    End If

    If cmbAge.Text <= 18 Then
        AdultCount += 1
    End If
End Sub

Private Sub btnResults_Click(sender As Object, e As EventArgs) Handles btnResults.Click

    Form2.Show()

    MalePercent = MaleCount / TotalGender * 100
    FemalePercent = FemaleCount / TotalGender * 100

    AdultPercent = AdultCount / TotalAge * 100
    ChildPercent = ChildCount / TotalAge * 100





End Sub

Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click


    TotalGender = 0
    TotalAge = 0
    MaleCount = 0
    FemaleCount = 0
    ChildCount = 0
    AdultCount = 0
    MalePercent = 0
    FemalePercent = 0
    AdultPercent = 0
    ChildPercent = 0
End Sub

结束Class

我的第二个表格已经放置了所有标签,我知道如何在标签上显示结果,我只是不知道如何将结果转移到另一个表格

你可以在表格 1 上写。它会在表格 2 上显示你的结果

Form2.Label1.Text = AdultCount
        Form2.Show()