タイトル | : Re: 文字列変換 |
記事No | : 13390 |
投稿日 | : 2009/02/02(Mon) 12:26 |
投稿者 | : 花ちゃん |
Split関数 と Join関数を使って下記のような感じにした方が簡単かな
Option Explicit
Private Sub Command1_Click() Debug.Print MySqlJoin("BETWEEN 2001/01/01 AND 2002/01/01") End Sub
Private Function MySqlJoin(ByVal myString As String) As String Dim AddDat As Variant Dim i As Long AddDat = Split(myString, " ") For i = LBound(AddDat) To UBound(AddDat) If AddDat(i) = "AND" Or AddDat(i) = "OR" Or _ AddDat(i) = "BETWEEN" Or AddDat(i) = "LIKE" Then Else AddDat(i) = "'" & AddDat(i) & "'" End If Next i MySqlJoin = Join(AddDat, " ") End Function 後は、追加条件やエラー処理等を付け足して下さい。
|