這次就沒有刻意照顧它,反而活得特別好,

前天發現有一顆番茄紅了,於是把它摘下來,長得還不錯
用手機拍還真是不容易

解析度不夠高,只好多拍幾張了,目前大約還有六顆未熟,也還在陸續開花中,應該可以全吃到吧!








Public Class frmNumericTxtBox
Private gstrTmpAs String = "" '記錄暫存的數值
''將TextBox1~4 KeyDown事件都納入Handle 的範圍
Private Sub TextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown, _
TextBox2.KeyDown, _
TextBox3.KeyDown, _
TextBox4.KeyDown()
''按下任一鍵時,取出目前的內容值
Dim myTxtBox As TextBox = Nothing
myTxtBox = sender
gstrTmp = myTxtBox.Text
End Sub
''將TextBox1~4 TextChanged事件都納入Handle 的範圍
Private Sub TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, _
TextBox2.TextChanged, _
TextBox3.TextChanged, _
TextBox4.TextChanged()
''判斷是否為數字,若不是則把暫存內容值填入
Dim myTxtBox As TextBox = Nothing
myTxtBox = sender
If myTxtBox.Text.Trim.Length > 0 Then
''限制只能輸入正數,包含小數,但不能有","
''因為IsNumeric 對於"," 會視為數字的一種
''若要有正負號則把InStr(myTxtBox.Text, "-") > 0 這個條件刪除
If IsNumeric(myTxtBox.Text) = False Then
Or InStr(myTxtBox.Text, " ") > 0 _
Or InStr(myTxtBox.Text, ",") > 0 _
Or InStr(myTxtBox.Text, "-") > 0 Then
myTxtBox.Text = gstrTmp '若其中一個條件不合,就把暫存的值填回TextBox中
myTxtBox.SelectionStart = myTxtBox.Text.Length
Else
gstrTmp = myTxtBox.Text.Trim
End If
Else
gstrTmp = ""
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
''按下加總時
Dim myTxtBox As TextBox = Nothing
Dim myControl As Control = Nothing
Dim mySum As Double = 0
''找出所有的Text Box 然後加總起來
For Each myControl In Me.Controls
If TypeOf myControl Is TextBox Then
myTxtBox = myControl
If myTxtBox.Text.Trim.Length > 0 And IsNumeric(myTxtBox.Text.Trim) = True Then
mySum = mySum + CType(myTxtBox.Text.Trim, Double)
End If
End If
Next
Label1.Text = "總和: " & vbCrLf & mySum.ToString
End Sub
End Class
=================================================Private Sub txtBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress,TextBox2.KeyPress _
TextBox3.KeyPress,TextBox4.KeyPress
'只允許輸入數字
' Chr(8) : BackSpace
If Not Char.IsDigit(e.KeyChar) AndAlso e.KeyChar <> Chr(8) AndAlso e.KeyChar <> "." Then e.Handled = True
End Sub
=================================================