「VB.NET」String.Format関数で文字を埋め込むサンプル

書式
String.Format(“値1:{0} 値2:{1}", 変数1, 変数2)
文字列に文字を埋め込めます
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Public Sub Main()
Dim strA As String = "東京"
Dim strB As String = "大阪"
Dim strC As String = "福岡"
Dim result As String = String.Format("都市1:{0} 都市2:{1} 都市3:{2}", strA, strB, strC)
Console.WriteLine(result)
Console.ReadKey()
End Sub
End Module
Module Module1 Public Sub Main() Dim strA As String = "東京" Dim strB As String = "大阪" Dim strC As String = "福岡" Dim result As String = String.Format("都市1:{0} 都市2:{1} 都市3:{2}", strA, strB, strC) Console.WriteLine(result) Console.ReadKey() End Sub End Module
Module Module1

    Public Sub Main()

        Dim strA As String = "東京"
        Dim strB As String = "大阪"
        Dim strC As String = "福岡"

        Dim result As String = String.Format("都市1:{0} 都市2:{1} 都市3:{2}", strA, strB, strC)
        Console.WriteLine(result)

        Console.ReadKey()
    End Sub

End Module

実行結果
都市1:東京 都市2:大阪 都市3:福岡

VB.net

Posted by arkgame