Results 1 to 5 of 5

Thread: Add Text To String

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Resolved Add Text To String

    My brain has gone blank.

    EntryRiskText (string variable) can either be Low, Med or High so depending on it's value, LowRiskCounter, MedRiskCounter or HighRiskCounter is checked. My problem is the 2nd line which returns an "Expected: expression" error and the first "&" is highlighted.

    Can anyone help me out?

    VB Code:
    1. If EntryRiskText & "RiskCounter" <> 10 Then
    2. EntryRiskText & "RiskCounter" = EntryRiskText & "RiskCounter" + 1
    3. End if
    [B]
    Last edited by lintz; May 3rd, 2005 at 09:44 PM.

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Add Text To String

    VB Code:
    1. EntryRiskText = EntryRiskText + 1 & "RiskCounter"

    that what you need?

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Add Text To String

    EntryRiskText is a String data type, and your concantinating it with an Integer (guess) and then evaluating it ??????

    VB Code:
    1. If EntryRiskText & "RiskCounter" <> 10 Then



    Should it be something like:
    VB Code:
    1. If (EntryRiskText = "Med") And (RiskCounter <> 10) Then




    Bruce.
    Last edited by Bruce Fox; May 3rd, 2005 at 09:47 PM.

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Add Text To String

    Quote Originally Posted by lintz
    My brain has gone blank.

    EntryRiskText (string variable) can either be Low, Med or High so depending on it's value, LowRiskCounter, MedRiskCounter or HighRiskCounter is checked. My problem is the 2nd line which returns an "Expected: expression" error and the first "&" is highlighted.

    Can anyone help me out?

    VB Code:
    1. If EntryRiskText & "RiskCounter" <> 10 Then
    2. EntryRiskText & "RiskCounter" = EntryRiskText & "RiskCounter" + 1
    3. End if
    [B]
    You need to do something else. You have no variable to add a value to.
    You would need something like this:
    VB Code:
    1. If LowRiskCounter.value = 1 then
    2.   eVal = 2
    3. end if
    4. if  MedRiskCounter.value = 1 then
    5.   eVal = eVal + 5
    6. end if
    7. if HighRiskCounter.value = 1 then
    8.   eval = eVal + 8
    9. end if
    10. EntryRisk.Text = & "RiskCounter = "  & eVal

  5. #5

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Add Text To String

    Not quite.

    If EntryRiskText = Low then the second line should read:

    LowRiskCounter = LowRiskCounter +1

    but instead of hard coding the Low (or Med/High) I use the varaible EntryRiskText

    EDIT: I posted to the first reply but have now read the others. Thanks

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