[VB.NET]Continue For文の利用サンプル

書式
Default Public ReadOnly Property Chars(index As Integer) As Char
現在の String オブジェクト内の指定された位置にある Char オブジェクトを取得します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Sub Main()
'文字列型変数の宣言
Dim src As String = "study skill in arkgame"
Dim rr As String = ""
'funcAメソッドを呼び出す
funcA(src, rr)
Console.ReadKey()
End Sub
'funcAメソッドの定義
Sub funcA(target As String,res As String)
'ループを実施
For i = 0 To target.Length - 1
'指定位置の文字判定
If target.Chars(i) = "k" Then
'ループを終了し次のループに移る
Continue For
End If
'文字列の連結
res = res + target.Chars(i)
Next i
'連結後文字列を出力
Console.WriteLine(res)
End Sub
End Module
Module Module1 Sub Main() '文字列型変数の宣言 Dim src As String = "study skill in arkgame" Dim rr As String = "" 'funcAメソッドを呼び出す funcA(src, rr) Console.ReadKey() End Sub 'funcAメソッドの定義 Sub funcA(target As String,res As String) 'ループを実施 For i = 0 To target.Length - 1 '指定位置の文字判定 If target.Chars(i) = "k" Then 'ループを終了し次のループに移る Continue For End If '文字列の連結 res = res + target.Chars(i) Next i '連結後文字列を出力 Console.WriteLine(res) End Sub End Module
Module Module1

    Sub Main()

        '文字列型変数の宣言
        Dim src As String = "study skill in arkgame"
        Dim rr As String = ""

        'funcAメソッドを呼び出す
        funcA(src, rr)

        Console.ReadKey()

    End Sub

    'funcAメソッドの定義
    Sub funcA(target As String,res As String)
        'ループを実施
        For i = 0 To target.Length - 1
            '指定位置の文字判定
            If target.Chars(i) = "k" Then
                'ループを終了し次のループに移る
                Continue For
            End If

            '文字列の連結
            res = res + target.Chars(i)
        Next i

        '連結後文字列を出力
        Console.WriteLine(res)
    End Sub

End Module

結果
study sill in argame

VB.net

Posted by arkgame