StdFuncクラス IntValメソッド
文字列を安全に整数に変換します。
テキストボックスに入力された数字文字列や、ファイルから読み込んだ数字などをデータに問題が有ってもエラーで処理を中断させる事無く数値に変換します。
扱える数値はIntegerの範囲です。文字列の先頭から評価し、「+-0123456789」これら12文字以外の文字が現れた時点で処理を終了します。
オーバーフローした場合もエラーを返さず、0を返します。
簡単に数値を扱う為の機能として用意されています。
使用法
Dim instance As StdFunc = New StdFunc()
Dim value As String
Dim returnValue As Integer
returnValue = instance.IntVal(value)
使用例
'StdFuncクラス IntValメソッド
Imports System.Windows.Forms
Public Class AddIn
Private stdf As StdFunc
Public Sub New()
stdf = New StdFunc()
Dim num1 As Integer = stdf.IntVal("-456")
Dim num2 As Integer = stdf.IntVal("12")
MessageBox.Show((num1 * num2).ToString)
End Sub
End Class