○VB6 String型文字列をchar配列のように扱う

'*********************************************
'String型文字列をchar配列として文字数を取得
'*********************************************
Function LenC(str As String) As Integer
    'char配列に変換して文字列の長さを取得
    LenC = LenB(StrConv(str, vbFromUnicode))
End Function

'*********************************************
'String型文字列をchar配列として文字列の切り出し
'*********************************************
Function MidC(str As String, start As Long, length As Long) As String
    'char配列に変換
    MidC = StrConv(str, vbFromUnicode)
    '配列の切り出し
    MidC = MidB(MidC, start, length)
    'unicodeに変換
    MidC = StrConv(MidC, vbUnicode)
End Function

Function MidC_(str As String, start As Long) As String
    'char配列に変換
    MidC_ = StrConv(str, vbFromUnicode)
    '配列の切り出し
    MidC_ = MidB(MidC_, start)
    'unicodeに変換
    MidC_ = StrConv(MidC_, vbUnicode)
End Function

'*********************************************
'String型文字列をchar配列として右端から文字列の切り出し
'*********************************************
Function RightC(str As String, length As Long) As String
    'char配列に変換
    RightC = StrConv(str, vbFromUnicode)
    '配列の切り出し
    RightC = RightB(RightC, length)
    'unicodeに変換
    RightC = StrConv(RightC, vbUnicode)
End Function

'*********************************************
'String型文字列をchar配列として左端から文字列の切り出し
'*********************************************
Function LeftC(str As String, length As Long) As String
    'char配列に変換
    LeftC = StrConv(str, vbFromUnicode)
    '配列の切り出し
    LeftC = LeftB(LeftC, length)
    'unicodeに変換
    LeftC = StrConv(LeftC, vbUnicode)
End Function



▲トップページ > Visual BASIC と C#