Function conversion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sport Girl
    New Member
    • Jul 2007
    • 42

    Function conversion

    Hello everybody,
    please can anybody help me about how can i convert these functions to a vb.net code in windows form application getting the same result.

    Code:
    Trim(sName) = Left(sTemp, InStr(sTemp, ",") - 1)
    
    sTemp = Right(sTemp, Len(sTemp) - InStr(sTemp, ","))
    Regards
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Sport Girl,

    This example shows you how to use the Split function to achieve the same results as above:
    Code:
    If sTemp.Contains(",") 
    		sName = sTemp.Split(",")(0)
    		sTemp = sTemp.Split(",")(1)
    End If
    Using Split breaks the string into an array of substrings using the specified character as a delimiter (in this case ","). In this way you can specify the index of the array (0 and 1 for the first two elements) to assign everything before the comma to one string and everything after the comma to another.

    Hope this helps,

    Dr B

    Comment

    • Sport Girl
      New Member
      • Jul 2007
      • 42

      #3
      Thank you very much.

      Comment

      Working...