Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Posts
    15

    Unanswered: how to convert string to character

    hello,
    I am using Visual Fox Pro 6.0. I have a form where have 4 text fields.
    1) IML No.
    2) New Part No.
    3) Original Part No.
    4) Employee ID
    (note: new part no.=original part no.)
    example:
    IML No.:15600001000 (scan barcode)
    New Part No.:fpt15600001000a3841750030 (scan barcode)
    Original Part No.:fpt15600001000a3841750030 (scan barcode)
    Employee ID:YY0111
    So, the system will compare the iml no.,new part no. and original part no. When the employee scan their employee id, pop up message either "Pass"(if iml no.=new part no.=original part no.) or "Fail'.
    The problem is the iml no. can't compare with the new part no. and original part no. The message always show "Fail". So what I want is when it compare the iml no., the first 3 digits and last 11 digits from the new part no. and original part no. are ignore.
    If there are solution to help me to solve this problem. Please help me.
    Thank you.

  2. #2
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Arrow mid function

    Hi

    im not fox programmer but vb
    but cant u use something like
    the mid function
    mid(string,start,length)

    so
    Original Part No = fpt15600001000a3841750030
    IML No =15600001000


    MyNo = Mid(Original Part No, 3, len(Original Part No))
    if MyNo = IML No then ok

  3. #3
    Join Date
    Aug 2004
    Posts
    15

    re:mid fuction

    thank you for your suggestion. but can you show me the full program of using the mid function because i am not so good in vb. so can you guide me to do the program.

    thank you.

  4. #4
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Post mid function

    Mid Function


    Returns a Variant (String) containing a specified number of characters from a string.

    Syntax

    Mid(string, start[, length])

    The Mid function syntax has thesenamed arguments:

    Part Description
    string Required.String expression from which characters are returned. If string containsNull, Null is returned.
    start Required;Long. Character position in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid returns a zero-length string ("").
    length Optional; Variant (Long). Number of characters to return. If omitted or if there are fewer than length characters in the text (including the character at start), all characters from the start position to the end of the string are returned.


    Remarks

    To determine the number of characters in string, use the Len function.

    Note Use the MidB function with byte data contained in a string, as in double-byte character set languages. Instead of specifying the number of characters, thearguments specify numbers of bytes. For sample code that uses MidB, see the second example in the example topic.

  5. #5
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Post Mid Function Example

    The first example uses the Mid function to return a specified number of characters from a string.

    Dim MyString, FirstWord, LastWord, MidWords
    MyString = "Mid Function Demo" ' Create text string.
    FirstWord = Mid(MyString, 1, 3) ' Returns "Mid".
    LastWord = Mid(MyString, 14, 4) ' Returns "Demo".
    MidWords = Mid(MyString, 5) ' Returns "Function Demo".

    The second example use MidB and a user-defined function (MidMbcs) to also return characters from string. The difference here is that the input string is ANSI and the length is in bytes.

    Function MidMbcs(ByVal str as String, start, length)
    MidMbcs = StrConv(MidB(StrConv(str, vbFromUnicode), start, length), vbUnicode)
    End Function

    Dim MyString
    MyString = "AbCdEfG"
    ' Where "A", "C", "E", and "G" are DBCS and "b", "d",
    ' and "f" are SBCS.
    MyNewString = Mid(MyString, 3, 4)
    ' Returns ""CdEf"
    MyNewString = MidB(MyString, 3, 4)
    ' Returns ""bC"
    MyNewString = MidMbcs(MyString, 3, 4)
    ' Returns "bCd"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •