CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Question Type Mismatch issue

    why i am getting type mismatch error in the following code ??? . kindly let me know the idea . any help would be highly appreciated !!!
    Code:
     
    
    
     Print #1, rs!QTY + "," + "",
         Print #1, rs!Price + ","
    Last edited by firoz.raj; March 20th, 2011 at 07:30 AM.

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

    Re: Type Mismatch issue

    You should use the ampersand '&' instead of the plus +' when concatenating strings.

  3. #3
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Question Re: Type Mismatch issue

    You should use the ampersand '&' instead of the plus +' when concatenating strings.
    Code:
    Print #1, "Saudi Arabia  ", "  """,
          Print #1, Day(Now); "," + "",
          Print #1, Format(Now, "mmm"); "," + "",
          Print #1, Year(Now); "," + "",
          Print #1, rs!STOREID & "," + "",
          Print #1, rs!itemid & "," + "",
          Print #1, rs!serial1 & "," + "",
          Print #1, rs!serial2 & "," + ""
          Print #1, rs!QTY & "," + "",
          Print #1, rs!Price & "," + ""
    Attached Files Attached Files

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

    Re: Type Mismatch issue

    I see + signs, still...
    Code:
    Print #1, "Saudi Arabia  ", "  """,
          Print #1, Day(Now); "," + "",
          Print #1, Format(Now, "mmm"); "," + "",
          Print #1, Year(Now); "," + "",
          Print #1, rs!STOREID & "," + "",
          Print #1, rs!itemid & "," + "",
          Print #1, rs!serial1 & "," + "",
          Print #1, rs!serial2 & "," + ""
          Print #1, rs!QTY & "," + "",
          Print #1, rs!Price & "," + ""
    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!

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

    Re: Type Mismatch issue

    Quote Originally Posted by dglienna View Post
    I see + signs, still...
    Code:
     
    Print #1, "Saudi Arabia  ", "  """,
          Print #1, Day(Now); "," + "",
          Print #1, Format(Now, "mmm"); "," + "",
          Print #1, Year(Now); "," + "",
          Print #1, rs!STOREID & "," + "",
          Print #1, rs!itemid & "," + "",
          Print #1, rs!serial1 & "," + "",
          Print #1, rs!serial2 & "," + ""
          Print #1, rs!QTY & "," + "",
          Print #1, rs!Price & "," + ""
    Yep lot's of em

    while + will work in many cases the & is the way to go, it always works and makes the code much easier to understand at a quick glance.

    also have no idea why this type of thing is even there
    Code:
    Print #1, rs!serial1 & "," + "",
    Print #1, rs!serial2 & "," + ""
    Adding an empty string to the end in these cases will do absolutely nothing beyond making the program slightly slower and require more time fromt he programmer who typed the extra characters into the editor.

    "," + "" = "," btw

    Also looks like there is a comma missing after serial2
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Question Re: Type Mismatch issue

    I see + signs, still... Code:
    Print #1, "Saudi Arabia ", " """, Print #1, Day(Now); "," + "", Print #1, Format(Now, "mmm"); "," + "", Print #1, Year(Now); "," + "", Print #1, rs!STOREID & "," + "", Print #1, rs!itemid & "," + "", Print #1, rs!serial1 & "," + "", Print #1, rs!serial2 & "," + "" Print #1, rs!QTY & "," + "", Print #1, rs!Price & "," + ""
    where + sign is missing ???.kindly put some color over it !!!!!!!!!!!.

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

    Re: Type Mismatch issue

    Go back and read it again...
    You should use the ampersand '&' instead of the plus +' when concatenating strings.
    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!

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