伊莉討論區
標題:
ACCESS 表單中複數文字方塊 求最大值?
[打印本頁]
作者:
da79317931
時間:
2015-4-8 11:45 PM
標題:
ACCESS 表單中複數文字方塊 求最大值?
本帖最後由 da79317931 於 2015-4-8 11:48 PM 編輯
請問一下各位大大,
小弟在表單中放入1,2,3,4,5(文字方塊)
表單中另有A文字方塊,希望能自動抓出上面5組之最大值,
B文字方塊,需抓出最小值。
盼各位大大指點迷津,感謝!
作者:
rr09192084
時間:
2015-4-12 12:57 PM
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim numstring As String = "1,2,3,4,5"
Dim numdata As String() = System.Text.RegularExpressions.Regex.Split(numstring, ",")
MessageBox.Show("最大值=" + GetMaxNum(numdata).ToString() + ", 最小值=" + GetMinNum(numdata).ToString())
End Sub
Private Function GetMaxNum(ByVal sa As String()) As Integer
Dim max As Integer
If sa.Count > 0 Then
max = System.Int32.Parse(sa(0))
End If
For Each n As String In sa
If System.Int32.Parse(n) > max Then
max = System.Int32.Parse(n)
End If
Next
Return max
End Function
Private Function GetMinNum(ByVal sa As String()) As Integer
Dim min As Integer
If sa.Count > 0 Then
min = System.Int32.Parse(sa(0))
End If
For Each n As String In sa
If System.Int32.Parse(n) < min Then
min = System.Int32.Parse(n)
End If
Next
Return min
End Function
複製代碼
看看你是不是要這個呢?
歡迎光臨 伊莉討論區 (http://a401.file-static.com/)
Powered by Discuz!