查看: 946|回复: 7
|
关于获取特定string的方法
[复制链接]
|
|
dim code as string
code = "HH1234 (23)"
我要如何才能取得"HH1234"?
并不能用 left (code,6),因为code可以是
HH11 (133)
HH88229 (13)
GFF13455 (45)
and etc
我觉得最好是有一个command可以detech到括弧() ,并将他remove掉
这样就可以不用管前面有多少个alphabet了.. |
|
|
|
|
|
|
|
发表于 7-6-2006 05:32 PM
|
显示全部楼层
|
|
|
|
|
|
|
楼主 |
发表于 10-6-2006 10:40 AM
|
显示全部楼层
Dim full = "BB1234/34"
Dim z as Integer = Instr(full, "/")
Compiler Error Message: BC30471: Expression is not an array or a method, and cannot have an argument list.
为何会出现error呢 (我是用在asp.net的)
[ 本帖最后由 一只优雅的猪 于 10-6-2006 10:41 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 10-6-2006 12:04 PM
|
显示全部楼层
Dim test As String = "BB1234/34"
Dim newstring As String = Left(test, InStr(test, "/") -1) |
|
|
|
|
|
|
|
楼主 |
发表于 10-6-2006 11:28 PM
|
显示全部楼层
i already change the code but the same error came out!!
Compiler Error Message: BC30471: Expression is not an array or a method, and cannot have an argument list. |
|
|
|
|
|
|
|
楼主 |
发表于 11-6-2006 10:28 AM
|
显示全部楼层
我现在用
Dim full = "BB1234/34"
Dim no = full.Substring(0, full.IndexOf("/"))
但return出来的result = 'BB1234'
我要的是 '34' |
|
|
|
|
|
|
|
发表于 11-6-2006 02:34 PM
|
显示全部楼层
原帖由 一只优雅的猪 于 11-6-2006 10:28 AM 发表
我现在用
Dim full = "BB1234/34"
Dim no = full.Substring(0, full.IndexOf("/"))
但return出来的result = 'BB1234'
我要的是 '34'
很简单... 你先了解情况以上的 code, substring 里的第一个 parameter 就可以了
你要用到的有 substring, indexof, 还有 length. |
|
|
|
|
|
|
|
楼主 |
发表于 11-6-2006 02:57 PM
|
显示全部楼层
解决了....
no = full.Substring(full.IndexOf("/") + 1) |
|
|
|
|
|
|
| |
本周最热论坛帖子
|