CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2011
    Posts
    34

    negative\postitive

    hi
    i want to be able to do this
    when the amount coming in is positive if returns a c and if amount is negative it returns a d
    this is what i have tried
    Code:
    If SNEX_ARRAY$(EXE_AMOUNT) < 0 Then
     SNEX_ARRAY$(EXE_CD) = "d"
     Else
      SNEX_ARRAY$(EXE_CD) = "C"
      End If
    any ideas why it doesnt work

  2. #2
    Join Date
    Oct 2006
    Posts
    327

    Re: negative\postitive

    Hello,

    very difficult to guess ..

    Is SNEX_ARRAY$ a function receiving EXE_AMOUNT as a parameter ?

    If so :
    Show the complete function code
    If not so (then it is an array) : explain (because I personnally would not undersatant "it returns ...")

  3. #3
    Join Date
    Jan 2000
    Location
    Saskatchewan, Canada
    Posts
    595

    Re: negative\postitive

    SNEX_ARRAY$(EXE_AMOUNT)

    The $ indicates the variable is a string. Possibly you need the value of this string

    Try Val(SNEX_ARRAY$(EXE_AMOUNT))

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: negative\postitive

    You say it doesn't work, what does it actually do?
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: negative\postitive

    Looks like QB 4.5 code
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: negative\postitive

    Yeah been a while since I have saw a $ used on a variable name but as far as I know it still works in VB6. Used to be required back in the day.
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: negative\postitive

    If SNEX_ARRAY$() is a string array, as may be supposed, the statement
    If SNEX_ARRAY$(EXE_AMOUNT) < 0 Then
    would certainly throw up a Type mismatch error.
    Is that what you get?

  8. #8
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: negative\postitive

    Actually if the variable contains a numeric value then the code will work just fine in VB6. if the string contains -1 then it will be true if it contains 1 then it will be false. If the string contains a non numeric value it will trigger a type mismatch error but since the poster did not tell us what it is doing there is not much way to say what the problem is other than to point out that you should use numeric variables for numeric operations even though you can sometimes get away with string variables.
    Always use [code][/code] tags when posting code.

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

Featured