以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  4个字符后面的部分字符,如何截取?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=177600)

--  作者:hbfnmxb
--  发布时间:2022/5/27 20:24:00
--  4个字符后面的部分字符,如何截取?
这种要求的字符串如何截取?
老师下面这段代码是截取字符串中的前4个字符,现在我需要截取前4个字符后面的部分,后面的字符没有固定长度,这个代码如何修改?
If e.DataCol.Name = "院校名称" Then
Dim s As String = e.DataRow("院校名称")
Dim V As Short = "4"
  If e.DataRow.IsNull("院校名称") OrElse e.DataRow.IsNull("院校名称") Then
      e.DataRow("院校编号") = Nothing
   Else
If v > 0 Then
      e.DataRow("院校编号") = left(s,v)
Else
      e.DataRow("院校编号") = right(s,v*-1)
End If
  End If
End If

谢谢老师

--  作者:hbfnmxb
--  发布时间:2022/5/28 8:20:00
--  
顶一下
--  作者:moseser
--  发布时间:2022/5/28 8:33:00
--  回复:(hbfnmxb)顶一下
先计算下字符串的长度 L  ,然后 用right 取 L-4 个字符串不就可以了么
--  作者:hbfnmxb
--  发布时间:2022/5/28 8:45:00
--  
现在是没有固定长度,这个L如何设置?
--  作者:有点蓝
--  发布时间:2022/5/28 9:04:00
--  
http://www.foxtable.com/webhelp/topics/0240.htm
--  作者:hbfnmxb
--  发布时间:2022/5/28 10:10:00
--  
If e.DataCol.Name = "院校名称" Then
Dim s As String = e.DataRow("院校名称")
Dim V As String
  If e.DataRow.IsNull("院校名称") OrElse e.DataRow.IsNull("院校名称") Then
      e.DataRow("院校编号") = Nothing
   Else
 V = s.SubString(2)
      e.DataRow("院校编号") = V
  End If
End If

谢谢老师。完成了