DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: MSForms.ReturnBoolean????

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    MSForms.ReturnBoolean????

    [Originally posted by Ed Ardzinski]

    I'm writing a VBA piece in Excel, and I'm trying to give the user a choice between double clicking on a file in a list box, or highlighting a file and hitting the enter key.

    Fine...I've done this many times before in Access, in VB...but I guess not in VBA Excel, since I can't call my routine.

    Here's the KeyDown event I'm trying:

    '*************************************
    Private Sub lstFiles_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

    If (KeyCode = vbKeyReturn) Then
    Call lstFiles_DblClick
    End If

    End Sub
    '*************************************

    The lstFiles_DblClick event has the type MSForms.ReturnBoolean as it's argument. Any other time I've tried this I have not needed to pass an argument, but the above code gives me "Argument is not optional". If I try to pass "False" or zero, I get Error 13 (type mismatch).

    And I can't find anything in the help files about "MSForms.ReturnBoolean".

    If anyone has encountered a similar situation,I'd appreciate the feedback.

    Edski

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:MSForms.ReturnBoolean????

    [Originally posted by Jim Cone]

    Edski,

    You need to use the double click event for the list box.
    The following is the actual code from one of my routines. It is in the code module for the form:

    '-----------------------------------------------
    Private Sub NamesListBox_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    OK_Button_Click
    End Sub
    '-----------------------------------------------
    Hope this helps.

    Jim Cone

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:MSForms.ReturnBoolean????

    [Originally posted by Ed Ardzinski]

    Jim, I'm trying to call the list box's double click event from a KeyPress event...or A KeyDown.

    The following works in Access (and I've done it in VB oftem enough), but in Access the argument of the Double Click event is an integer:

    '*****************
    Private Sub List0_DblClick(Cancel As Integer)
    Text2 = List0
    End Sub

    Private Sub List0_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = vbKeyReturn) Then
    List0_DblClick (0)
    End If
    End Sub
    '*****************

    I tried declaring a variable of the type MSForms.ReturnBoolean, and the autotype function in the VBA Editor suggests true or false as values for this variable...but the errors I get suggest that this is an object variable that must be set. When I use "Set rbNo = False" I get the type mismatch.

    All very odd...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center