2016-03-21 5 views
0

それは正確に9桁の数字/文字にする必要がありチェックならば、

if abc.text = (some 9 digits/characeters) then 

Endif 

のようなものが...その後だけではif文の中に入る

任意のアイデアあります? ?

あなたの文字列の長さが9に等しいかどうかをチェックすることができます
+6

私は@NicoSchertler ....それをupvoteことができますので、 'abc.Text.Length = 9' –

+0

ああ、ありがとう、答えに書きます –

答えて

3

If abc.Text.Length = 9 Then 
    'ToDo 
EndIf 
1

あなたが唯一の番号または文字にcontraintしたい場合は、単にしかし、私たち

If abc.text.Lenght = 9 Then 

End IF 

な長さを確認したい場合

Dim objRegExp As New System.Text.RegularExpressions.Regex("^[a-zA-Z0-9]{9}$") 
If objRegExp.Match(abc).Success 

End If 

をインポートすることを忘れないでくださいreqular表現を使います

Imports System.Text.RegularExpressions 
0
Module Module1 

Sub Main() 
    Dim x As String = Console.ReadLine() 
    If (x.Length = 9) Then 
     Console.WriteLine("We have nine character") 
    Else 
     Console.WriteLine("we have {0} character .", x.Length) 
    End If 
    Console.ReadKey() 
End Sub 

エンドモジュール

関連する問題