'เป็นฟังก์ชันครับ สามารถสร้าง Class ได้แล้วให้เรียกใช้เอานะครับ
Option Explicit On
Option Strict On
Public Class CurrencyTextBox
Public Shared Function CurrencyOnly(ByVal TargetTextBox As TextBox, ByVal CurrentChar As Char) As Boolean
If IsNumeric(CurrentChar) = True Then
Return False
End If
If CBool(((Convert.ToString(CurrentChar) = "." AndAlso CBool(InStr(TargetTextBox.Text, "."))))) Then
Return True
End If
If Convert.ToString(CurrentChar) = "." OrElse CurrentChar = vbBack Then
Return False
End If
Return True
End Function
Public Shared Function StringOnly(ByVal TargetTextBox As TextBox, ByVal CurrentChar As Char) As Boolean
If IsNumeric(CurrentChar) = True Then
Return True
End If
Dim objWebClient As New WebClient()
Dim strUrl As String = "https://www.thaicreate.com"
Dim byteRequestedHtml() As Byte
byteRequestedHtml = objWebClient.DownloadData(strUrl)
Dim objUtf8 As New UTF8Encoding()
Dim strRequestedHtml As String
strRequestedHtml = objUtf8.GetString(byteRequestedHtml)
Label1.Text = strRequestedHtml
'เป็นฟังก์ชันครับ สามารถสร้าง Class ได้แล้วให้เรียกใช้เอานะครับ
Option Explicit On
Option Strict On
Public Class CurrencyTextBox
Public Shared Function CurrencyOnly(ByVal TargetTextBox As TextBox, ByVal CurrentChar As Char) As Boolean
If IsNumeric(CurrentChar) = True Then
Return False
End If
If CBool(((Convert.ToString(CurrentChar) = "." AndAlso CBool(InStr(TargetTextBox.Text, "."))))) Then
Return True
End If
If Convert.ToString(CurrentChar) = "." OrElse CurrentChar = vbBack Then
Return False
End If
Return True
End Function
Public Shared Function StringOnly(ByVal TargetTextBox As TextBox, ByVal CurrentChar As Char) As Boolean
If IsNumeric(CurrentChar) = True Then
Return True
End If