請問VB 2010 textbox 問題?

請問各位前輩 若我要用button分別記錄三個時間

button1.text= 00.00 (ps.同2 3)

Private Sub button1_click (ps.同2 3)

button1.text= now.hour & now.minute

End Sub

Private Sub button4_click

Form2.Show()

End Sub

Private Sub Form2_Load

textbox1.text = Form1.button1.text &

vbCrLf & Form1.button2.text &

vbCrLf & Form1.button3.text

End Sub

倘若我按其中兩個記錄時間,另一個沒記到為不變(text=00.00)

然後如何在form2的textbox中 不顯示不變的button.text=00.00

1 個解答

評分
  • John
    Lv 7
    2 年前
    最佳解答

    Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Button1.Text = Format(Now, "hh.mm")

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

    Button2.Text = Format(Now, "hh.mm")

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

    Button3.Text = Format(Now, "hh.mm")

    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

    Form2.Show()

    End Sub

    End Class

    Public Class Form2

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles Me.Load

    Dim result As String

    result = GetTimerAsString(Form1.Button1.Text)

    result = result + GetTimerAsString(Form1.Button2.Text)

    result = result + GetTimerAsString(Form1.Button3.Text)

    Me.TextBox1.Text = result

    End Sub

    Private Function GetTimerAsString(ByVal timer As String) As String

    GetTimerAsString = ""

    If Not "00.00" = timer Then

    GetTimerAsString = timer & vbCrLf

    End If

    End Function

    End Class

還有問題?馬上發問,尋求解答。