SSブログ

Excel2000 VBA 文字列操作 /(スラッシュ)で区切られた文字列を分解 [Excel2000 VBA 文字列操作]

Excel2000 VBA  文字列操作 /(スラッシュ)で区切られた文字列を分解

goo天気から取得した最高気温、最低気温の文字列"34 / 28 "を分解する。

Sub 最高最低気温分解()
'goo天気の最低気温、最高気温の文字列を分解する
'
Dim temperature As String
Dim strA, strB  As Variant
Dim i, temperatureHL(1) As Integer
'文字設定
    temperature = "34 / 28 "    '34最高気温 28最低気温
'spaceを削除
    temperature = Replace(temperature, " ", "")   'spaceをnullに置換
'区切り文字 / で展開
    strA = Split(temperature, "/")

    For Each strB In strA
        temperatureHL(i) = CInt(strB)   'temperatureHL(0)に34 temperatureHL(1)に28
        i = i + 1                         'Cint()で文字を数値(integer)に変換
    Next
'MsgBoxに表示
    MsgBox temperatureHL(0) & vbCrLf + vbCrLf & temperatureHL(1)
End Sub


タグ:Excel2000 VBA
nice!(0)  コメント(0)  トラックバック(0) 
共通テーマ:パソコン・インターネット

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。