Quantcast
Channel: OKWAVE 最新質問([技術者向] コンピューター/205)【本日】
Viewing all articles
Browse latest Browse all 38062

コードに無駄が多すぎる気がする

$
0
0
http://hiroba.chintai.net/qa7900795.html こちらでも質問したものなのですが、ご提示いただいた内容が難しくてよくわからなかった為 自分でコードを作ったのですが、無駄が多すぎるような気がするので見てもらえますか? やりたい事は、フォーム上のコントロールをタブインデックス順に取得したいのですが --------------------------------------------------------- Option Compare Database Option Explicit Sub test() Dim ctl As Control Dim i As Integer Dim j As Integer Dim intTabIndex As Integer Dim StrFormName As String StrFormName = "SampleCode_SubForm" DoCmd.OpenForm StrFormName, acDesign For i = 0 To Forms(StrFormName).Controls.Count - 1 For j = 0 To Forms(StrFormName).Controls.Count - 1 Set ctl = Forms(StrFormName).Controls.Item(j) If Forms(StrFormName).Controls.Item(j).ControlType = acTextBox Then 'TabIndexがないコントロールはエラーになる。 ' Debug.Print "TabIndex:" & Forms(StrFormName).Controls.Item(j).TabIndex Do While Forms(StrFormName).Controls.Item(j).TabIndex = intTabIndex '数が小さい順からTabIndexを照合していく(0~コントロールの最大値) Debug.Print "TabIndex:" & Forms(StrFormName).Controls.Item(j).TabIndex & " " & Forms(StrFormName).Controls.Item(j).Name intTabIndex = intTabIndex + 1 Exit For '該当のTabIndexが見つかったのなら抜ける Loop End If Next j Next i End Sub --------------------------------------------------------- これで一応取得できるのですが、かなり無駄があるように感じます。 フォームをループして一つずつコントロールを見て行ってるのですがもっと簡略化できないでしょうか? ご回答よろしくお願いします。

Viewing all articles
Browse latest Browse all 38062

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>