カテゴリー
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
1,918 views

ApplyFilter

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

1,582 views

テーブル保存時にエラーメッセージ

テーブルのデザインを変更して保存する時、フィールド数が最大値(255)に達していないのに
「定義されているフィールドが多すぎます」となる時。
ACCESSでは、テーブルごとにフィールドのカウント値を持っている。
フィールドを追加した時と同様にフィールドのプロパティを変更した時にもそのカウンターがインクリメントされる。
これはフィールドを削除してもカウンターは変更されない。

【解決法】
・データベースを最適化/修復する
・テーブルをコピーする

5,935 views

テキストファイル読み書き関数

'# テキストファイルを一括読み込み
Private Function ReadFile(strFilename As String) As String

    Dim nFNO        As Integer 'ファイル番号
    Dim strData     As String

    nFNO = FreeFile '空ファイル番号取得
    Open strFilename For Input As #nFNO
    strData = StrConv(InputB(LOF(1), #nFNO), vbUnicode)
    Close #nFNO '閉じる

    ReadFile = strData

End Function

続きを読む…»

1,818 views

オートメーション

AccessからOfficeアプリケーションを制御すること

1,848 views