以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]字符串中有(时取前五位 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=91060) |
-- 作者:ajie5211 -- 发布时间:2016/9/28 15:01:00 -- [求助]字符串中有(时取前五位 1022AYY(2XX-1)A
1022CYYXXA
WJ2EDGK-10.16-XXP-2YY-02A 以上三个字符串(数组lhs),希望得到如下字符串(数组dlhs)
1022A
1022C
WJ2EDGK-10.16-XXP-2YY-02A
代码如下不成功
Dim lhs As new List(of String)
Dim dlhs As new List(of String) For Each lh As String In lhs Select Case lh.Length Case < 12 dlhs.Add(lh.SubString(0,5)) Case > 11 If lh.Contains("(") = 1 Then dlhs.Add(lh.SubString(0,5)) Else dlhs.add(lh) End If End Select Next
求方案! |
-- 作者:有点蓝 -- 发布时间:2016/9/28 15:14:00 -- For Each lh As String In lhs If lh.Length < 12 dlhs.Add(lh.SubString(0,5)) Else If lh.Contains("(") Then dlhs.Add(lh.SubString(0,5)) Else dlhs.add(lh) End If End If Next
|
-- 作者:ajie5211 -- 发布时间:2016/9/28 15:19:00 -- 还是不行, 1022AYY(2XX-1)A 这种的取的不对。![]() ![]() |
-- 作者:ajie5211 -- 发布时间:2016/9/28 15:23:00 -- 以下是引用有点蓝在2016/9/28 15:14:00的发言:
For Each lh As String In lhs
If lh.Length < 12
dlhs.Add(lh.SubString(0,5))
Else
If lh.Contains("(") Then
dlhs.Add(lh.SubString(0,5))
Else
dlhs.add(lh)
End If
End If
Next 还是不行,数据输入时,有可能用了全角,这个怎么办? |
-- 作者:有点蓝 -- 发布时间:2016/9/28 15:34:00 -- 参考http://www.foxtable.com/webhelp/scr/1621.htm |