必ず使うシリーズ VBA VBS文字列などをDoubleQuotationでWrappingする関数

# WrappingDoubleQuotation Function
ダブルクォーテーションで何でもラッピングする
日付、日時は適当に変換する
用途としては改行を伴う文字列、SQL、CSV、など見た目がすっきりするため必要。

```visualbasic
Function RpDqt(varString) ' As String
' String Return With DoubleQuotation Such As
' Dog => "Dog"
' wRapping with DoubleQuTation
On Error Resume Next
If TypeName(VarString) ="Date" Then
RpDqt=chr(34) & CDate(varString) & chr(34)
Else
RpDqt=chr(34) & Cstr(varString) & chr(34)
End If
Exit Function
On Error Goto 0
If Err.Number <> 0 Then
Err.Clear
RpDqt=chr(34) & chr(34)
Exit Function
End If
End Function
```

# WRappingDoubleQuotationWithComma Function
Wrapping Double Quotation And And Comma
Wrappingした後にコンマをつける

```visualbasic
Function RpDqtc(varString) ' As String
' String Return With DoubleQuotation Such As
' Dog => "Dog" ,
' wRapping with DoubleQuoTation
'RpDqtc=chr(34) & varString & chr(34) & ","
On Error Resume Next
If TypeName(VarString) ="Date" Then
RpDqtc=chr(34) & CDate(varString) & chr(34) & chr(44)
Else
RpDqtc=chr(34) & Cstr(varString) & chr(34) & chr(44) 
End If
Exit Function
On Error Goto 0
If Err.Number <> 0 Then
Err.Clear
RpDqtc=chr(34) & chr(34)  & chr(44)
Exit Function
End If
End Function
```
# Wrapping DoubleQuotation add VbCrlf
ラッピングした後に、改行を追加する。
CSVファイルを作るときは、ここが1行の終わりになる。
2019/2/27 RpDqRに関数名を変更しました。

```visualbasic
Function RpDqR(varString) ' As String
' String Return With DoubleQuotation Such As
' Dog => "Dog" & VbCrLf
' wRapping with DoubleQuoTation
On Error Resume Next
If TypeName(VarString) ="Date" Then
RpDqR=chr(34) & CDate(varString) & chr(34) & vbCrLf
Else
RpDqR=chr(34) & Cstr(varString) & chr(34) & VbCrLf
End If
Exit Function
On Error Goto 0
 If Err.Number <> 0 Then
 'Wscript.Echo Err.Number, Err.Description
  Err.Clear
  RpDqR=chr(34) & chr(34)  & VbCrLf : Exit Function
  End If
End Function
```

# Wrapping DoubleQuotation add VbCrlf
ラッピングした後、2つあけて改行する
4つの要素（4列）が1行にあってつ要素が2つしかない場合、2つ目に使う

```visualbasic
Function RpDqtccR(varString) ' As String
' String Return With DoubleQuotation Such As
' Dog => "Dog" , "","" & VbCrLf
' wRapping with DoubleQuoTation
RpDqtccR=chr(34) & varString & chr(34) & "," & """""" & "," & """""" & VbCrLf
End Function

```

# Wrapping DoubleQuotation SingleQuotation SingleQuotation DobuleQuotation

```visualbasic
Function RpDqSqSqDq(VarString) ' As String
' Dog => "'Dog'"
IF TypeName(varString)="Date" Then
RpDqSqSqDq=chr(34) & chr(39) & Cdate(varString) & chr(39) & chr(34)
Else
On Error Resume Next
RpDqSqSqDq=chr(34) & chr(39) & CStr(varString) & chr(39) & chr(34)
End Function
 If Err.Number<>0 Then
 'Wscript.Echo Err.Number, Err.Description
  Err.Clear
  RpDqSqSqDq=chr(34) & chr(39) & chr(39) & chr(34)
  End If
End If
End Function
```

#Wrapping DoubleQuotation SingleQuotation SingleQuotation DobuleQuotation Add Comma
```visualbasic
Function RpDqSqSqDqc(VarString) ' As String
' Dog => "'Dog'",
RpDqSqSqDqc=chr(34) & chr(39) & cstr(varString) & chr(39) & chr(34) & ","
End Function
```
#Wrapping Double Quotation And Deliminator
Double Quotationで囲み、任意の区切り文字を追加する

```visualbasic
Function RpDqtDlim(varString,strDelim) ' As String
' Update 2019/02/20
' String Return With DoubleQuotation,strDelim=";" Such As
' Dog => "Dog" ;
' Wrapping with DoubleQuoTation Add strDelim
'RpDqtDlim=chr(34) & varString & chr(34) & strDelime
On Error Resume Next
If TypeName(VarString) ="Date" Then
RpDqtDlim=chr(34) & CDate(varString) & chr(34) & strDelim
Else
RpDqtDlim=chr(34) & Cstr(varString) & chr(34) & strDelim
End If
Exit Function
    On Error Goto 0
    If Err.Number <> 0 Then
    'Wscript.Echo Err.Number, Err.Description
    Err.Clear
    RpDqtDlim=chr(34) & chr(34)  & strDelim
    Exit Function
    End If
End Function
```