ไม่แน่ใจว่าตรงคำถามหรือป่าวนะ แฮร่ๆ
Public Function isNumeric(input As String) As Boolean
Return Regex.IsMatch(input.Trim, "\A-{0,1}[0-9.]*\Z")
End Function
Dim NUMQTYI1 As String = IIf(CType(range.Cells(rCnt, 14), Excel.Range).Value = Nothing, "0", CType(range.Cells(rCnt, 14), Excel.Range).Value)
Dim NumQTY As Object = NUMQTYI1
Dim ChecknumericQTY As Boolean
ChecknumericQTY = IsNumeric(NumQTY)
If ChecknumericQTY = True Then
UNPD_QTY = NUMQTYI1
End If
Code (VB.NET)
Dim CharPortT1 As String = IIf(CType(range.Cells(16, 7), Excel.Range).Value = Nothing, "", CType(range.Cells(16, 7), Excel.Range).Value)
Dim CharPort As Object = CharPortT1
Dim CheckCharPort As String
CheckCharPort = TypeName(CharPort)
If CheckCharPort = TypeName(CharPort) = True Then
UNP_PORT = CharPortT1
End If