Results 1 to 7 of 7

Thread: ismissing

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Location
    Belgium (Bruges)
    Posts
    88

    ismissing

    Private Sub Command1_Click()
    f1
    End Sub
    Private Sub Command2_Click()
    f2
    End Sub

    Private Sub f1(Optional a As Variant)
    MsgBox IsMissing(a)
    End Sub

    Private Sub f2(Optional a As Integer)
    MsgBox IsMissing(a)
    End Sub

    the function only works with the variant type

    is there another way to use this
    Greetz matthias

  2. #2
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    use this:

    Code:
    in the Ismissing function just add this:
    
    
    if isnumeric(a) then
    
    a=     cstr(a)
    end if
    
    'further your code

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    FROM MSDN :
    IsMissing(argname)
    The required argname argument contains the name of an optional Variant procedure argument.
    Maybe something like this : (If this doesn't do it, let me know the data type you want other than th variant)
    Code:
    Private Sub f1(Optional a As String) 
        If IsNull(a) Then Msgbox "Not Here"
    End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    Talking

    Perphaps I am sleepy

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Location
    Belgium (Bruges)
    Posts
    88
    It doesnt work i changed the code a bit

    Private Sub Command1_Click()
    f1
    End Sub
    Private Sub Command2_Click()
    f2
    End Sub

    'Private Sub f1(Optional a As Variant)
    ' MsgBox IsMissing(a)
    'End Sub

    Private Sub f1(Optional a As String)
    If IsNull(a) Then MsgBox "Not Here"
    End Sub

    Private Sub f2(Optional a As Integer)
    MsgBox TypeName(a)
    MsgBox IsNull(a)
    If IsNull(a) Then
    MsgBox "tis null"
    End If
    MsgBox IsMissing(a)
    End Sub

    when i press button 1 the functions should show the msgbox with the text not here but nothing appears ...
    Greetz matthias

  6. #6
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179
    because you are DECLARING the optional variable, it is initialized to its default value.

    so if you are using a variant, it can have an 'ismissing' value.

    but a string is initialized as "" (empty 'string').

    so to check this, instead of 'ismissing' use
    Code:
    if a = "" then
    msgbox "is missing"
    else
    msgbox "is not missing (" & a  & ")"
    end if

  7. #7
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    That's why I asked the data type - if it's a string, you can check for a vbnullstring value.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width