Results 1 to 8 of 8

Thread: objAttributes help adding an If statement?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    113

    objAttributes help adding an If statement?

    using his code as an example

    Code:
    Select Case objAttributes.Name
    
    Case Is = "Attribute"
    
    'do task with attribute
    
    End Select
    The code will search for the required case attribute from the list of attributes in objAttributes.Name, is there an alternative way of doing this?

    Also is it possible to add an If statement to this? My goal is this...

    Code:
     """If"""" Select Case objAttributes.Name
    
    Case Is = "Attribute"  """"If Case Attribute Exists, Then""""
    
    'do task with attribute
    
    End Select
    """Else""" After the End Select?
    'do a different task

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: objAttributes help adding an If statement?

    I don't understand your IF's. The .Name property either has a value or doesn't
    Code:
    Select Case objAttribute.Name
        Case "Attribute"
            ' do something
        Case "Genre"
            ' do something else
        Case "Gender"
            ' do yet something else
    
        ... more case statements
    
        Case Else
            ' the property value is not handled
    End Select
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    113

    Re: objAttributes help adding an If statement?

    I'll give that ago, thanks!


    I take it there's no other way to handle the .Name attribute other than Case?

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: objAttributes help adding an If statement?

    Well, you could use IFs
    Code:
    If objAttribute.Name = "Attribute" Then
    
    ElseIf objAttribute.Name = "Genre" Then 
    
    ElseIf objAttribute.Name = "Gender" Then
    
    ' add more ElseIf statements as needed
    
    Else
           ' the property value is not handled
    End If
    Edited: If what was posted does not work for you, you might want to give greater details and specific examples.
    Last edited by LaVolpe; Sep 17th, 2009 at 05:46 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    113

    Re: objAttributes help adding an If statement?

    The problem I'm having is the Attribute.Name contains multiple values now

    If objAttribute.Name = "Attribute" Then

    ' Write to column

    ' column = column + 1

    Else
    ' column = column + 1

    End If

    I want the column to add +1 if the attribute exists or if it doesn't however because the objAttribute.Name contains multiple values it will add ' column = column + 1 for every value I only want this code "' column = column + 1" to run if the attributes exists or doesn't not run every time the objAttribute.Name is checked...

    Can anyone suggest a possible workaround?

  6. #6
    Junior Member
    Join Date
    Sep 2009
    Posts
    18

    Re: objAttributes help adding an If statement?

    i donot get it full but can say
    if objAttribute.Name has alot of values
    and you wnt to add column + 1 order in any case then you donot need if statment just
    write
    column = column + 1

    if i didnot get it explain more

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    113

    Re: objAttributes help adding an If statement?

    Basically I ONLY want to add the +column IF the value exists or not.

    I’ll try and explain how the code will work


    ‘ Write to column

    ‘Check for attribute

    ‘If it exists write to column Then column + 1
    (This function could check for multiple attributes so when it writes I need it to move to the next column)

    ‘Else column + 1
    (Because the code writes to the column at the start if NO attribute exists then I want the code to add a column)

  8. #8
    Junior Member
    Join Date
    Sep 2009
    Posts
    18

    Re: objAttributes help adding an If statement?

    look
    If objAttribute.Name = "Attribute" Then

    ' Write to column

    ' column = column + 1

    Else
    ' column = column + 1

    End If

    equal

    If objAttribute.Name = "Attribute" Then

    ' Write to column

    End If

    ' column = column + 1

    do u use loop for check ?
    and wt u means with exists ?
    and if dosenot exist it gives error ?

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