Dim newForm As New Form
Dim a As New Label
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim subj As String = ""
Dim show As String = ""
Dim Teacher As String = "" '準備放到newform Label的字串
Dim score As Integer
Dim b As Integer
Dim c As Integer
'Create Newform
newForm.Text = "上課老師"
newForm.FormBorderStyle _
= Windows.Forms.FormBorderStyle.FixedSingle
newForm.StartPosition = FormStartPosition.CenterScreen
newForm.Size = New Size(200, 200)
newForm.BackColor = Color.Yellow
newForm.Opacity = 0.8
show &= "選課資料如下:" & vbCrLf
show &= "-------------------------------" & vbCrLf
show &= "科目" & vbTab & vbTab & "學分" & vbCrLf
show &= "-------------------------------" & vbCrLf
For Each subj In ListBox1.Items
Select Case subj
Case "國文"
score = 4
b = b + 4
c = c + 1
Teacher &= "國文:李國文 老師" & vbNewLine
Case "英文"
score = 3
b = b + 3
c = c + 1
Teacher &= "英文:陳英文 老師" & vbNewLine
Case "數學"
score = 5
b = b + 5
c = c + 1
Teacher &= "數學:王數學 老師" & vbNewLine
End Select
show &= subj & vbTab & vbTab & score & vbCrLf
Next
show &= "-------------------------------" & vbCrLf
show &= "總計:" & c & "科目," & b & "學分" & vbCrLf
a.Margin = New Padding(5, 5, 0, 0)
a.Font = New Font("Arial", 12)
a.Dock = DockStyle.Fill
a.Text = Teacher '把teacher值放到newform的label
newForm.Controls.Add(a)
newForm.Show()
End Sub
Dim a As New Label
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim subj As String = ""
Dim show As String = ""
Dim Teacher As String = "" '準備放到newform Label的字串
Dim score As Integer
Dim b As Integer
Dim c As Integer
'Create Newform
newForm.Text = "上課老師"
newForm.FormBorderStyle _
= Windows.Forms.FormBorderStyle.FixedSingle
newForm.StartPosition = FormStartPosition.CenterScreen
newForm.Size = New Size(200, 200)
newForm.BackColor = Color.Yellow
newForm.Opacity = 0.8
show &= "選課資料如下:" & vbCrLf
show &= "-------------------------------" & vbCrLf
show &= "科目" & vbTab & vbTab & "學分" & vbCrLf
show &= "-------------------------------" & vbCrLf
For Each subj In ListBox1.Items
Select Case subj
Case "國文"
score = 4
b = b + 4
c = c + 1
Teacher &= "國文:李國文 老師" & vbNewLine
Case "英文"
score = 3
b = b + 3
c = c + 1
Teacher &= "英文:陳英文 老師" & vbNewLine
Case "數學"
score = 5
b = b + 5
c = c + 1
Teacher &= "數學:王數學 老師" & vbNewLine
End Select
show &= subj & vbTab & vbTab & score & vbCrLf
Next
show &= "-------------------------------" & vbCrLf
show &= "總計:" & c & "科目," & b & "學分" & vbCrLf
a.Margin = New Padding(5, 5, 0, 0)
a.Font = New Font("Arial", 12)
a.Dock = DockStyle.Fill
a.Text = Teacher '把teacher值放到newform的label
newForm.Controls.Add(a)
newForm.Show()
End Sub