[VB.NET]文字列の空白を削除するサンプル

2021年9月10日

書式
文字列..Replace(" “, “"))

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Imports System.Text.RegularExpressions
Module Module1
Sub Main()
'
Dim strA As String = "te st 234 "
Console.WriteLine("置換前文字列: " + strA)
'指定文字を空白を削除
Console.WriteLine("置換後文字列: " + strA.Replace(" ", ""))
Console.ReadKey()
End Sub
End Module
Imports System.Text.RegularExpressions Module Module1 Sub Main() ' Dim strA As String = "te st 234 " Console.WriteLine("置換前文字列: " + strA) '指定文字を空白を削除 Console.WriteLine("置換後文字列: " + strA.Replace(" ", "")) Console.ReadKey() End Sub End Module
Imports System.Text.RegularExpressions
Module Module1

    Sub Main()
        '
        Dim strA As String = "te st 234 "


        Console.WriteLine("置換前文字列: " + strA)
        '指定文字を空白を削除
        Console.WriteLine("置換後文字列: " + strA.Replace(" ", ""))

        Console.ReadKey()

    End Sub

End Module

結果
置換前文字列: te st 234
置換後文字列: test234

VB.net

Posted by arkgame