String Functions

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

    String Functions

    What string function will cut off the last 3 characters from a string?

    For example: if I had the string,

    dim strtext as string = testcalls


    I want to only return the strtext as test and take off the calls.
  • kimiraikkonen

    #2
    Re: String Functions

    On Apr 1, 5:37 pm, cmdolcet69 <colin_dolce... @hotmail.comwro te:
    What string function will cut off the last 3 characters from a string?
    >
    For example: if I had the string,
    >
    dim strtext as string = testcalls
    >
    I want to only return the strtext as test and take off the calls.
    Substring function.

    Your example is not well-formed but i guess it's:
    Dim strtext As String = "testcalls"

    To display only "test" chars from whole "testcalls" word;

    Substring(0,4)

    which defines 0 is startIndex point and 4 is the length that belongs
    the length of "test".


    Comment

    • cmdolcet69

      #3
      Re: String Functions

      On Apr 1, 10:51 am, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
      On Apr 1, 5:37 pm, cmdolcet69 <colin_dolce... @hotmail.comwro te:
      >
      What string function will cut off the last 3 characters from a string?
      >
      For example: if I had the string,
      >
      dim strtext as string = testcalls
      >
      I want to only return the strtext as test and take off the calls.
      >
      Substring function.
      >
      Your example is not well-formed but i guess it's:
      Dim strtext As String = "testcalls"
      >
      To display only "test" chars from whole "testcalls" word;
      >
      Substring(0,4)
      >
      which defines 0 is startIndex point and 4 is the length that belongs
      the length of "test".

      What happends if i dont know the lenght. Because the lenght may change.

      Comment

      • Jack Jackson

        #4
        Re: String Functions

        On Tue, 1 Apr 2008 08:02:04 -0700 (PDT), cmdolcet69
        <colin_dolcetti @hotmail.comwro te:
        >On Apr 1, 10:51 am, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
        >On Apr 1, 5:37 pm, cmdolcet69 <colin_dolce... @hotmail.comwro te:
        >>
        What string function will cut off the last 3 characters from a string?
        >>
        For example: if I had the string,
        >>
        dim strtext as string = testcalls
        >>
        I want to only return the strtext as test and take off the calls.
        >>
        >Substring function.
        >>
        >Your example is not well-formed but i guess it's:
        >Dim strtext As String = "testcalls"
        >>
        >To display only "test" chars from whole "testcalls" word;
        >>
        >Substring(0, 4)
        >>
        >which defines 0 is startIndex point and 4 is the length that belongs
        >the length of "test".
        >
        >
        >What happends if i dont know the lenght. Because the lenght may change.
        Dim strtext As String = "testcalls"

        strtext = strtext.Substri ng(0, strtext.Length - 3)

        But I think you really want 5 instead of 3 since "calls" is 5
        characters long, not 3.

        or:
        strtext = strtext.Substri ng(0, strtext.Length - "calls".Len gth)

        or
        strtext = strtext.Remove( strtext.Length - "calls".Len gth)


        Comment

        Working...