Left of a character in a string in vb.net

前端 未结 8 1191
耶瑟儿~
耶瑟儿~ 2021-01-03 20:24

say if I have a string 010451-09F2

How to I get left of - from the above string in vb.net

I want 010451

The left fu

相关标签:
8条回答
  • 2021-01-03 21:18

    Use something like this:

    Mid("010451-09F2",1,InStr("-"))

    0 讨论(0)
  • 2021-01-03 21:27
        Dim sValue As String = "010451-09F2"
        Debug.WriteLine(sValue.Substring(0, sValue.IndexOf("-"c)))
    
    0 讨论(0)
提交回复
热议问题