VB6 Chr() function (should be simple) issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Benry

    VB6 Chr() function (should be simple) issue

    I have two machines. Both have Windows xp Pro. Both have Visual
    Studio 6.0. These two versions differ only in Forms3 version. Machine
    1 (M1) has version 11.0.6254, Machine 2 (M2) has version
    11.0.6550...oth er than that, I'm hardpressed to find anything
    significient that's different.

    The question I have is, on M1, the Chr() function will return the
    proper value for input values 0-255, however, on M2, the Chr() function
    will return the proper value for input values 0-127, and return 0 for
    input values 128-255. I realize that this has something to do with the
    ANSI or ASCII encoding scheme...but how do I fix it? How do I get M2
    to return the proper values for ALL inputs from 0-255???

    Thank you.

  • Martin H.

    #2
    Re: VB6 Chr() function (should be simple) issue

    Hello Benry,
    The question I have is, on M1, the Chr() function will return the
    proper value for input values 0-255, however, on M2, the Chr() function
    will return the proper value for input values 0-127, and return 0 for
    input values 128-255. I realize that this has something to do with the
    ANSI or ASCII encoding scheme...but how do I fix it? How do I get M2
    to return the proper values for ALL inputs from 0-255???
    As with all character queries, please keep in mind that VB6 does not
    support Unicode.

    In the Windows control panel you might check the Regional and Language
    Options (Advanced tab - only available with an Administrator account)
    what the Language for non-Unicode programs is. Perhaps it's Chinese,
    Japanese or another 2byte language setting?

    Best regards,

    Martin

    P.S. As this is a dotnet newsgroup, you might want to ask your question
    in microsoft.publi c.vb which covers classic VB (<=VB6).

    Comment

    • Newbie Coder

      #3
      Re: VB6 Chr() function (should be simple) issue

      This is not a VB6 newsgroup Benry

      For a good forum with VB6 is http://www.developerfusion.co.uk because there
      are so many users & you'll get an almost immediate response

      I hope this will be more beneficial to you


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: VB6 Chr() function (should be simple) issue

        "Martin H." <hkshk@gmx.nets chrieb:
        >The question I have is, on M1, the Chr() function will return the
        >proper value for input values 0-255, however, on M2, the Chr() function
        >will return the proper value for input values 0-127, and return 0 for
        >input values 128-255. I realize that this has something to do with the
        >ANSI or ASCII encoding scheme...but how do I fix it? How do I get M2
        >to return the proper values for ALL inputs from 0-255???
        >
        As with all character queries, please keep in mind that VB6 does not
        support Unicode.
        That's wrong. VB6 strings are actually Unicode strings and VB6 supports
        'ChrW' and 'AscW' which support Unicode. Using 'ChrW' and 'AscW' instead of
        'Chr' and 'Asc' can be done in both VB6 and VB.NET to deal with Unicode
        instead of ANSI.

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

        Comment

        • Benry

          #5
          Re: VB6 Chr() function (should be simple) issue



          On Jan 24, 3:30 pm, "Martin H." <h...@gmx.netwr ote:
          Hello Benry,
          >
          The question I have is, on M1, the Chr() function will return the
          proper value for input values 0-255, however, on M2, the Chr() function
          will return the proper value for input values 0-127, and return 0 for
          input values 128-255. I realize that this has something to do with the
          ANSI or ASCII encoding scheme...but how do I fix it? How do I get M2
          to return the proper values for ALL inputs from 0-255???As with all character queries, please keep in mind that VB6 does not
          support Unicode.
          >
          In the Windows control panel you might check the Regional and Language
          Options (Advanced tab - only available with an Administrator account)
          what the Language for non-Unicode programs is. Perhaps it's Chinese,
          Japanese or another 2byte language setting?
          >
          Best regards,
          >
          Martin
          >
          P.S. As this is a dotnet newsgroup, you might want to ask your question
          in microsoft.publi c.vb which covers classic VB (<=VB6).
          Thanks, I'll direct these questions appropriately in the future. I
          will try your proposed resolution as well. Thank you.

          Comment

          • Benry

            #6
            Re: VB6 Chr() function (should be simple) issue

            yeah, thanks.

            On Jan 24, 3:35 pm, "Newbie Coder" <newbie_co...@p leasespamme.com >
            wrote:
            This is not a VB6 newsgroup Benry
            >
            For a good forum with VB6 ishttp://www.developerfu sion.co.ukbecau se there
            are so many users & you'll get an almost immediate response
            >
            I hope this will be more beneficial to you

            Comment

            • Benry

              #7
              Re: VB6 Chr() function (should be simple) issue



              On Jan 24, 3:34 pm, "Herfried K. Wagner [MVP]"
              <hirf-spam-me-h...@gmx.atwrot e:
              "Martin H." <h...@gmx.netsc hrieb:
              >
              The question I have is, on M1, the Chr() function will return the
              proper value for input values 0-255, however, on M2, the Chr() function
              will return the proper value for input values 0-127, and return 0 for
              input values 128-255. I realize that this has something to do with the
              ANSI or ASCII encoding scheme...but how do I fix it? How do I get M2
              to return the proper values for ALL inputs from 0-255???
              >
              As with all character queries, please keep in mind that VB6 does not
              support Unicode.That's wrong. VB6 strings are actually Unicode strings and VB6 supports
              'ChrW' and 'AscW' which support Unicode. Using 'ChrW' and 'AscW' instead of
              'Chr' and 'Asc' can be done in both VB6 and VB.NET to deal with Unicode
              instead of ANSI.
              I tried ChrW, and from parameter values 128-255, I get
              garbage...meani ng...non-deterministic responses. Most of the return
              values are 0x3F. I'll ask this question in the appropriate forum.
              Thank you.

              -Benry

              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: VB6 Chr() function (should be simple) issue

                "Benry" <henrybg@gmail. comschrieb:
                I tried ChrW, and from parameter values 128-255, I get
                garbage...meani ng...non-deterministic responses. Most of the return
                values are 0x3F. I'll ask this question in the appropriate forum.
                I am not sure how you determine the return value. Both 'Chr' and 'ChrW'
                return a character and not a number.

                --
                M S Herfried K. Wagner
                M V P <URL:http://dotnet.mvps.org/>
                V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                Comment

                • Cor Ligthert [MVP]

                  #9
                  Re: VB6 Chr() function (should be simple) issue

                  Herfried,

                  That somebody makes a typo does not mean that his solution is wrong.

                  Now it is maybe not a typo but an explanation which is wrong. That still
                  makes in my idea the solution right.

                  Your messages gave at my idea the idea that the complete solution was wrong.
                  The reaction from the OP acknowledge this. Can you correct this yourself.

                  Thanks in advance.

                  Cor

                  "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atschr eef in bericht
                  news:O1Jk3ABQHH A.4016@TK2MSFTN GP04.phx.gbl...
                  "Martin H." <hkshk@gmx.nets chrieb:
                  >>The question I have is, on M1, the Chr() function will return the
                  >>proper value for input values 0-255, however, on M2, the Chr() function
                  >>will return the proper value for input values 0-127, and return 0 for
                  >>input values 128-255. I realize that this has something to do with the
                  >>ANSI or ASCII encoding scheme...but how do I fix it? How do I get M2
                  >>to return the proper values for ALL inputs from 0-255???
                  >>
                  >As with all character queries, please keep in mind that VB6 does not
                  >support Unicode.
                  >
                  That's wrong. VB6 strings are actually Unicode strings and VB6 supports
                  'ChrW' and 'AscW' which support Unicode. Using 'ChrW' and 'AscW' instead
                  of 'Chr' and 'Asc' can be done in both VB6 and VB.NET to deal with Unicode
                  instead of ANSI.
                  >
                  --
                  M S Herfried K. Wagner
                  M V P <URL:http://dotnet.mvps.org/>
                  V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                  Comment

                  • Cor Ligthert [MVP]

                    #10
                    Re: VB6 Chr() function (should be simple) issue

                    Hi

                    We did not solicitate for a policeman in this newsgroup. There are enough
                    who can do that if that is needed. However those give as well other answers
                    and redirect if needed inside the Microsoft range of newsgroups.

                    Cor

                    "Newbie Coder" <newbie_coder@p leasespamme.com schreef in bericht
                    news:euHhuABQHH A.4492@TK2MSFTN GP02.phx.gbl...
                    This is not a VB6 newsgroup Benry
                    >
                    For a good forum with VB6 is http://www.developerfusion.co.uk because
                    there
                    are so many users & you'll get an almost immediate response
                    >
                    I hope this will be more beneficial to you
                    >
                    >

                    Comment

                    • Benry

                      #11
                      Re: VB6 Chr() function (should be simple) issue

                      This is the code I used:

                      Dim sTemp As String
                      For a = 0 To 255
                      sTemp = sTemp & Hex(Asc(Chr$(a) )) & " "
                      Next a
                      MsgBox sTemp

                      When the message box came up, it printed from 0->7F and then 128 0's
                      and then FF. I don't get it.

                      On every other machine I try this code, it works fine, but it's just
                      this one machine.

                      -Benry

                      On Jan 24, 4:53 pm, "Herfried K. Wagner [MVP]"
                      <hirf-spam-me-h...@gmx.atwrot e:
                      "Benry" <henr...@gmail. comschrieb:
                      >
                      I tried ChrW, and from parameter values 128-255, I get
                      garbage...meani ng...non-deterministic responses. Most of the return
                      values are 0x3F. I'll ask this question in the appropriate forum.I am not sure how you determine the return value. Both 'Chr' and 'ChrW'
                      return a character and not a number.
                      >
                      --
                      M S Herfried K. Wagner
                      M V P <URL:http://dotnet.mvps.org/>
                      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                      Comment

                      • Herfried K. Wagner [MVP]

                        #12
                        Re: VB6 Chr() function (should be simple) issue

                        "Benry" <henrybg@gmail. comschrieb:
                        This is the code I used:
                        >
                        Dim sTemp As String
                        For a = 0 To 255
                        sTemp = sTemp & Hex(Asc(Chr$(a) )) & " "
                        Next a
                        MsgBox sTemp
                        >
                        When the message box came up, it printed from 0->7F and then 128 0's
                        and then FF. I don't get it.
                        >
                        On every other machine I try this code, it works fine, but it's just
                        this one machine.
                        Maybe the machines use different Windows ANSI code pages.

                        However, I am wondering why you are not just writing 'sTemp & Hex$(a) & "
                        "'.

                        --
                        M S Herfried K. Wagner
                        M V P <URL:http://dotnet.mvps.org/>
                        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                        Comment

                        • Benry

                          #13
                          Re: VB6 Chr() function (should be simple) issue

                          On Jan 26, 3:32 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
                          h...@gmx.atwrot e:
                          "Benry" <henr...@gmail. comschrieb:
                          >
                          This is the code I used:
                          >
                          Dim sTemp As String
                          For a = 0 To 255
                          sTemp = sTemp & Hex(Asc(Chr$(a) )) & " "
                          Next a
                          MsgBox sTemp
                          >
                          When the message box came up, it printed from 0->7F and then 128 0's
                          and then FF. I don't get it.
                          >
                          On every other machine I try this code, it works fine, but it's just
                          this one machine.
                          >
                          Maybe the machines use different Windows ANSI code pages.
                          >
                          However, I am wondering why you are not just writing 'sTemp & Hex$(a) & "
                          "'.
                          This was my test to see how Chr() works on a particular machine. On
                          one machine, this code outputs correctly, on the machine I'm having
                          problems with, this code does not work for 128 <= a < 255.

                          How do I change/update ANSI code pages?

                          -Benry

                          Comment

                          Working...