問題
オブジェクトを検出してそれに応じて動作する機能があります。ただし、ラベルオブジェクトまたはテキストボックスオブジェクトは常に、それらをラベルおよびテキストボックスとして検出しないため、if
条件をスキップします。ちなみに、すべてのオブジェクトはユーザーフォームからのものです。奇妙なことに、コンボボックスオブジェクトを検出し、if
条件を正しく実行することができます
私のコード
Public Function enterObjectsValue(ByVal uiObject As Object)
If TypeOf uiObject Is Label Then
Cells(DeviceSheetLastEmptyCell, headerColumn).Value = uiObject.Caption
End If
If TypeOf uiObject Is TextBox Or TypeOf uiObject Is ComboBox Then
Cells(DeviceSheetLastEmptyCell, headerColumn).Value = uiObject.Value
End If
End Function
上記の関数を以下のように呼び出します
Call enterObjectsValue(mainPage.customerGroup)
誰かが理由を知っていますか?
この場合、msforms.TextBoxなどを使用します。
Public Function enterObjectsValue(ByVal uiObject As Object)
If TypeOf uiObject Is msforms.Label Then
'Cells(DeviceSheetLastEmptyCell, headerColumn).Value = uiObject.Caption
Debug.Print uiObject.Caption
End If
If TypeOf uiObject Is msforms.TextBox Or TypeOf uiObject Is msforms.ComboBox Then
'Cells(DeviceSheetLastEmptyCell, headerColumn).Value = uiObject.Value
Debug.Print uiObject.Value
End If
End Function
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加