「VB.net」CCharでString式の最初の文字をchar型に変換

2021年9月10日

書式
CChar
任意の有効な Char または String 式。String の最初の文字のみが変換されます。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Sub Main()
Dim str, strB As String
Dim resChar As Char
str = "BMW"
strB = ",INFO"
'CChar関数を使用して、文字列の最初の文字をCharに変換
resChar = CChar(str)
Console.WriteLine(resChar)
resChar = CChar(strB)
Console.WriteLine(resChar)
Console.ReadKey()
End Sub
End Module
Module Module1 Sub Main() Dim str, strB As String Dim resChar As Char str = "BMW" strB = ",INFO" 'CChar関数を使用して、文字列の最初の文字をCharに変換 resChar = CChar(str) Console.WriteLine(resChar) resChar = CChar(strB) Console.WriteLine(resChar) Console.ReadKey() End Sub End Module
Module Module1

    Sub Main()

        Dim str, strB As String
        Dim resChar As Char

        str = "BMW"
        strB = ",INFO"
        'CChar関数を使用して、文字列の最初の文字をCharに変換
        resChar = CChar(str)

        Console.WriteLine(resChar)

        resChar = CChar(strB)

        Console.WriteLine(resChar)

        Console.ReadKey()

    End Sub

End Module

結果
B
,

VB.net

Posted by arkgame