TOP > Up > Today

Re: アクセルでの電話番号の形式を作りたいのですが。


Date:  Wed, 22 Sep 2004 13:21:53 +0900
Subject:  [pasml 51815] Re: アクセルでの電話番号の形式を作りたいのですが。
=== 本メールマガジンへの返信はなさらないで下さい ===
=== 投稿はパソコン困りごと掲示板で願いいたします ===
=== 掲示板URL: http://pasokoma.jp/   ===
----------------------------------------------------
お名前   : unknown 困りごと掲示板から
URL      : 
質問URL:http://pasokoma.jp/bbs.cgi?num=203178&ope=v
ツリートップ:http://pasokoma.jp/cgi/tree.cgi?num=203178
----------------------------------------------------
ももんがさんは No.203150「アクセルでの電話番号の形式を作りたいのですが。」で書きました。
>アクセスの入力画面にて、0000-00-0000と00-0000-0000と
>入力できるように設定したいのです。
>どちらかは無理ですか?
>でしたら片方だけでも教えて下さるとありがたいです。
ACCESS専用の掲示板は結構あるみたいです
http://www.google.com/search?num=50&lr=lang_ja&q=ms+access+%E6%8E%B2%E7%A4%BA%E6%9D%BF
入力するテキストボックス(txt0)の更新後処理のイベントプロージャで
“-”を取っ払うのはどうでしょう
参考
#適当に自作なので使用は自己責任でお願いします
Private Sub txt0_AfterUpdate()
     'エラー処理なし
    Dim str_a, str_b As String
    Dim int_i1, int_i2, int_k As Integer
    If Not IsNull(Me![txt0]) Then
        '半角に変換
        str_a = StrConv(Me![txt0], 8)
        '文字数を調べる
        int_k = Len(str_a)
        '"-"の場所探す
        int_i1 = InStr(str_a, "-")
        int_i2 = InStr(int_i1 + 1, str_a, "-")
        '一個目の"-"が存在
        If int_i1 > 1 Then
            str_b = Left(str_a, int_i1 - 1)
            '二個目の"-"が存在
            If int_i2 > 1 Then
                str_b = str_b + Mid(str_a, int_i1 + 1, int_i2 - int_i1 - 1)
                str_b = str_b + Mid(str_a, int_i2 + 1, int_k - int_i2)
            Else
            '二個目なし
                str_b = str_b + Mid(str_a, int_i1 + 1, int_k - int_i1)
            End If
                Me![txt0] = str_b
        Else
        '"-"なし
        End If
    End If
End Sub
----------------------------------------------------
-- メール配信の停止: http://pasokoma.jp/taikai.shtml
-- 全国パソコン先生検索&登録: http://pas2.ann.co.jp/
----------------------------------------------------
    


TOP > Up > Today