カテゴリー
SugiBlog Webエンジニアのためのお役立ちTips

配列に値を追加する関数

Private Function array_push(source As Variant, destination As String, flag As Boolean) As String

    Dim Ary() As String
    Dim delimiter As String

    Select Case (flag)
       
        Case True  '選択地域文字列
            delimiter = " "
       
        Case False '選択地域
            delimiter = ":"
   
    End Select

    If InStr(source, destination) < 0 Then
        array_push = source
        Exit Function
    End If

    If Not IsNull(source) Then
        Ary = Split(source, delimiter)
        ReDim Preserve Ary(UBound(Ary) + 1) As String
        Ary(UBound(Ary)) = destination
        array_push = Join(Ary, delimiter)
        array_push = value_splice(array_push, ":")
        DoEvents
        array_push = repRecur(array_push, ":")
    Else
        array_push = destination
    End If

End Function
2,044 views

ファイル名を変更

ファイル名を変更するには、DirectoryクラスのMove()メソッドを使用します。

//現在の名前と新しい名前を引数に指定します。
Directory.Move("Test.txt", "Test.bak");

※但し、異なるボリューム間は移動できない

異なるボリューム間で移動したい場合はFileInfoクラスを使用します。

FileInfo fInfo = new FileInfo ("Test.txt");
fInfo.MoveTo("Test.bak");

※但し、移動先に同名のファイルが存在すればエラーが発生

1,779 views

ACCESSエラー「指定したテーブルから削除できませんでした。」

テーブルにリレーションシップを組んであるため、
削除クエリでレコードを削除できない場合の解決法 

クエリのプロパティで、固有のレコード(UniqueRecords)を「はい」にする

6,786 views

ComboBoxにまとめて値を追加する

string[] str = new string[]{"amanda", "burkley", "circle"};
ComboBox1.Items.AddRange(str);
3,858 views

ApplyFilter

引数 WhereCondition の最大長は 32,768 文字です。
マクロ ウィンドウでは、これとは異なり、”Where Condition/Where 条件式” アクション引数の最大長は 256 文字です。

1,703 views