Results 1 to 6 of 6

Thread: [RESOLVED] problem comparing values

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    49

    Resolved [RESOLVED] problem comparing values

    Hi everyone,

    I am trying to read in a string containing numerical values and keep a running total of a field. The field contains values such as 000001.15 (preceeding zeros and 2 decimal points.)

    my declarations are as follows

    Dim runTotal_NetPaid_GT_ZERO(6) As Currency
    Dim netPaid As Currency

    netPaid = CCur(SH_NetPaid) ' field which contains the string
    The problem I have is when I use "netPaid" to make a comparison.

    Select Case netPaid

    Case netPaid = 0

    Case netPaid > 0

    Case Else

    End Select
    Even though the value is zero in Debug, the highlighted code does not get executed. Any ideas on why this is?

    Thanks for your help

    Gogi

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: problem comparing values

    It is because you aren't using the Select Case quite right - the variable should only appear on the first line of it, and not on the actual Case's.

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: problem comparing values

    also check this for me...

    Insert this line
    Code:
    MsgBox Format(netPaid, "$#,##0.00")
    before the
    Code:
        Select Case netPaid
    and tell me what do you get?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    49

    Re: problem comparing values

    Hi

    Thanks for the reply guys.

    koolsid:

    MsgBox Format(netPaid, "$#,##0.00") this gives me $14.00

    netPaid = CCur(SH_NetPaid) gives me 14

    which is why I thought 000000.00 will give me 0 therefore that select case should work.

    si_the_geek:
    I see your point, but how will I deal with values greater than 0. will this work
    Case Is > 0. I suppose I should try, shouldn't I?

    Thanks

  5. #5
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: problem comparing values

    Case Is > 0. I suppose I should try, shouldn't I?
    Yes you are right...

    Code:
    Select Case netPaid
        Case 0
            'your code
        Case Is > 0
            'your code
        Case Else
            'your code
    End Select
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    49

    Re: problem comparing values

    Thanks for your hel guys, I can go home know.

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