Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to use Substr in Visual Basic.Net

how to use Substr in Visual Basic.Net

Scheduled Pinned Locked Moved Visual Basic
csharphelptutorialquestion
5 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Swiss Mantoro
    wrote on last edited by
    #1

    Hi.... I need to know how to use Substr operation inside Visual Basic.Net language program, because I could not found it,could you mind to help me please ? Thank you for your attention and your help in advance Best regards :-D ICE

    S 1 Reply Last reply
    0
    • S Swiss Mantoro

      Hi.... I need to know how to use Substr operation inside Visual Basic.Net language program, because I could not found it,could you mind to help me please ? Thank you for your attention and your help in advance Best regards :-D ICE

      S Offline
      S Offline
      soodmonu
      wrote on last edited by
      #2

      You can try like this. dim xyz as string xyz.substring(startindex) and other overloaded form of this function is xyz.substring(startindex, length)

      S 1 Reply Last reply
      0
      • S soodmonu

        You can try like this. dim xyz as string xyz.substring(startindex) and other overloaded form of this function is xyz.substring(startindex, length)

        S Offline
        S Offline
        Swiss Mantoro
        wrote on last edited by
        #3

        Hi Soodmonu many thank for your reply I have tried that operation but it doesn't working well, and Now I saw you my simple program as follows dim a as double dim b,c as string a=03.00 b=str(a) c=b,substring(4,2) when I tried to run my program an error message was come, I wanna to show two last character from "a" into my screen and it supposed to be "00" but I could not catch it, could you mind to tell me how to do that ? Thank you ICE

        S 1 Reply Last reply
        0
        • S Swiss Mantoro

          Hi Soodmonu many thank for your reply I have tried that operation but it doesn't working well, and Now I saw you my simple program as follows dim a as double dim b,c as string a=03.00 b=str(a) c=b,substring(4,2) when I tried to run my program an error message was come, I wanna to show two last character from "a" into my screen and it supposed to be "00" but I could not catch it, could you mind to tell me how to do that ? Thank you ICE

          S Offline
          S Offline
          soodmonu
          wrote on last edited by
          #4

          Here the problem is type casting from double to string. let me explain you.... first of all when u declare a double variable as 03.00, the value stored in variable will be 3.0 and when u type cast it to string, it will store as "3" only. so as you can see there is no fourth character in string, substring does not return anything. now what you can do that is : Dim a, c As String a = "03.00" c = a.Substring(3, 2) here in the substring function index is a zero based index, so you have to pass 3 to get the fourth character. and if you donot want to declare as string in the starting and want to proceed with double only, then find some help on double.tostring() function, i think that function can help it should be like Dim x As Double Dim a, c As String x = 3.0 a = x.ToString("0#.00") c = a.Substring(3, 2) Arpan :-D -- modified at 8:47 Thursday 29th June, 2006

          S 1 Reply Last reply
          0
          • S soodmonu

            Here the problem is type casting from double to string. let me explain you.... first of all when u declare a double variable as 03.00, the value stored in variable will be 3.0 and when u type cast it to string, it will store as "3" only. so as you can see there is no fourth character in string, substring does not return anything. now what you can do that is : Dim a, c As String a = "03.00" c = a.Substring(3, 2) here in the substring function index is a zero based index, so you have to pass 3 to get the fourth character. and if you donot want to declare as string in the starting and want to proceed with double only, then find some help on double.tostring() function, i think that function can help it should be like Dim x As Double Dim a, c As String x = 3.0 a = x.ToString("0#.00") c = a.Substring(3, 2) Arpan :-D -- modified at 8:47 Thursday 29th June, 2006

            S Offline
            S Offline
            Swiss Mantoro
            wrote on last edited by
            #5

            Hi. Soodmonu I have tried it and thank's it's running well, thank you for your help Best regards :) ICE

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups