draemonash2のメモ書き
'連続した空白を一つにまとめる
Do While InStr(sTrgtLine, " ")
sTrgtLine = Replace$(sTrgtLine, " ", " ")
Loop
sTrgtLine = Trim$(sTrgtLine)
asSplitLine = Split(sTrgtLine, " ")
'Classモジュール ClassString
Public Function GetDup( _
ByVal sVal As String
) As String
GetDup = sVal & sVal
End Function
'Classモジュール ClassCom
Public STR As New ClassString
'標準モジュール Module1
Public C As New ClassCom
Sub Test02()
Debug.Print C.STR.GetDup("はい")
End Sub
Private Sub Class_Initialize()
End Sub
Public Function Execute() As String
End Function
Implements ClassCmn
Dim a As String
Private Sub Class_Initialize()
a = "A"
End Sub
Public Function ClassCmn_Execute() As String
ClassCmn_Execute = a
End Function
Implements ClassCmn
Dim b As String
Private Sub Class_Initialize()
b = "B"
End Sub
Public Function ClassCmn_Execute() As String
ClassCmn_Execute = b
End Function
Sub test()
Dim clChkExecTable(1) As ClassCmn
Set clChkExecTable(0) = New Class1
Set clChkExecTable(1) = New Class2
Debug.Print clChkExecTable(0).Execute
Debug.Print clChkExecTable(1).Execute
End Sub
記号 | 意味 | 使用例 | マッチする文字列 |
---|---|---|---|
? | 任意の1文字 | たな? | たなか、たなべ、たなし(など) |
* | 0個以上の任意の文字 | たか* | たかだ、たかなか、たかやなぎ(など) |
# | 1文字の数値(0~9) | ## | 01、26、95(など) |
[charlist] | charlistに指定した文字の中の1文字 | [A-F] | A、B、C、D、E、F |
[!charlist] | charlistに指定した文字の中に含まれない1文字 | [!A-F] | G 、H、I(など) |
Sub main()
On Error Resume Next
On Error Resume Next
Call subfunction
Debug.Print 5 / 0 '⇒実行時エラー無し
On Error GoTo 0
'Debug.Print 5 / 0 '⇒実行時エラーが発生してプログラムが停止する。
On Error GoTo 0
End Sub
Sub subfunction()
On Error Resume Next
Debug.Print 5 / 0 '⇒実行時エラー無し
On Error GoTo 0
Debug.Print 5 / 0 '⇒実行時エラー無し
End Sub
データ型 | 名称 | 消費メモリ | 格納できる範囲 |
---|---|---|---|
Integer | 整数型 | 2バイト | -32,768 ~ 32,767 |
Long | 長整数型 | 4バイト | -2,147,483,648 ~ 2,147,483,647 |
Single | 単精度浮動小数点数型 | 4バイト | -3.402823E38 ~ -1.401298E-45(負の値) 1.401298E-45 ~ 3.402823E38(正の値) |
Double | 倍精度浮動小数点数型 | 8バイト | -1.79769313486232E308 ~ -4.94065645841247E-324(負の値) 4.94065645841247E-324 ~ 1.79769313486232E308(正の値) |
Currency | 通貨型 | 8 バイト | -922,337,203,685,477.5808 ~ 922,337,203,685,477.5807 |
String | 文字列型 | 2バイト | 最大約20億文字まで |
Date | 日付型 | 8 バイト | 西暦100 年1月1日~西暦9999年12月31日までの日付と時刻 |
Object | オブジェクト型 | 4 バイ | オブジェクトを参照するデータ型 |
Variant | バリアント型 | 16バイト | 可変長の文字列型の範囲と同じ。 |
Boolean | ブール型 | 2 バイト | 真 (True) または偽 (False) |
演算子 | 意味 | 変数への代入例 |
---|---|---|
+ | 加算する | i = 15 + 5 ( i の値は20) |
- | 減算する | i = 15 - 5 ( i の値は10) |
* | 乗算する | i = 5 * 4 ( i の値は20) |
/ | 除算する | i = 15 / 5 ( i の値は3) |
¥ | 除算の商 | i = 15 \ 2 ( i の値は7) |
Mod | 除算の余り | i = 15 Mod 2 ( i の値は1) |
^ | べき乗する | i = 2 ^ 5 ( i の値は32) |
定数 | エラー番号 | セルのエラー値 |
---|---|---|
xlErrDiv0 | 2007 | #DIV/0! |
XlErrNA | 2042 | #N/A |
xlErrName | 2029 | #NAME? |
XlErrNull | 2000 | #NULL! |
XlErrNum | 2036 | #NUM! |
XlErrRef | 2023 | #REF! |
XlErrValue | 2015 | #VALUE! |
参照方法 | A1 表記 | R1C1 表記 | 説明 |
---|---|---|---|
相対参照 | =A1 | =R[-2]C[-2] | A1セルはC3セルから見て2行手前の2列手前のセル |
絶対参照 | =$A$1 | =R1C1 | A1セルはどこから見てもA列の第1行目のセル |
Dim oPriceOfFruit As Object
Debug.Print oPriceOfFruit Is Nothing 'True
Debug.Print oPriceOfFruit.Count 'エラー
Set oPriceOfFruit = CreateObject("Scripting.Dictionary")
Debug.Print oPriceOfFruit Is Nothing 'False
Debug.Print oPriceOfFruit.Count '0
oPriceOfFruit.Add "リンゴ", "100円"
Debug.Print oPriceOfFruit Is Nothing 'False
Debug.Print oPriceOfFruit.Count '1
oPriceOfFruit.Remove ("リンゴ")
Debug.Print oPriceOfFruit Is Nothing 'False
Debug.Print oPriceOfFruit.Count '0
Set oPriceOfFruit = Nothing
Debug.Print oPriceOfFruit Is Nothing 'True
'Debug.Print oPriceOfFruit.Count 'エラー
For iRowIdx = .Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
For iChkTargetRowIdx = iRowIdx - 1 To 2 Step -1
If .Cells(iRowIdx, 1) = .Cells(iChkTargetRowIdx, 1) Then
.Cells(iChkTargetRowIdx, 1).EntireRow.Delete Shift:=xlShiftUp
Else
'Do Nothing
End If
Next iChkTargetRowIdx
Next iRowIdx
Dim spTxtBox As Shape
Set spTxtBox = shTrgtSht.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=10, _
Top:=10, _
Width:=10, _
Height:=10 _
)
With spTxtBox
.TextFrame.Characters.Text = "エラーフレームなし"
.TextFrame.AutoSize = True
End With
Ctrl | Shift | Alt | Key | 機能 |
---|---|---|---|---|
F5 | 実行 | |||
F8 | ステップイン | |||
Shift | F8 | ステップオーバー | ||
Ctrl | Shift | F8 | ステップアウト | |
F2 | ウィンドウ表示/移動 オブジェクト移動 | |||
F4 | ウィンドウ表示/移動 プロパティ | |||
F7 | ウィンドウ表示/移動 コード | |||
Ctrl | G | ウィンドウ表示/移動 イミディエイト | ||
Ctrl | R | ウィンドウ表示/移動 プロジェクトエクスプローラー | ||
Ctrl | ↑/↓ | プロシージャ移動 前/次 | ||
Ctrl | Space | 入力候補の表示 | ||
/Shift | F2 | タグジャンプ/バックタグジャンプ | ||
Ctrl | Break | マクロ強制終了 |