以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  【已解决】爱恨交集的If else end if  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=176890)

--  作者:kylin
--  发布时间:2022/4/30 1:33:00
--  【已解决】爱恨交集的If else end if
Dim cn = e.DataCol.Name 
Dim dr = e.DataRow
If cn = "ClnBD" Then
    Dim rs As String = dr!ClnBD 
    Dim bfh As String
    \'合格判断
    Dim fhs() = {"月", ".", "/", "\\", "-"}
    Dim cs As Integer = 0
    For Each fh As String In fhs
        If rs.IndexOf(fh) > -1 Then
            cs = cs + 1
        End If 
    Next 
    If cs = 0 Or cs > 1 Then
        bfh = "格式不符合"
    Else
        If rs.IndexOf("月") > -1 Then
            If rs.Length - rs.Replace("月", "").Length > 1 Then
                bfh = "格式不符合"
            ElseIf rs.Length - rs.Replace("年", "").Length > 1 Then
                bfh = "格式不符合"
            End If
        End If 
    End If
    If bfh > "" Then
        
    Else
        \' 五种情况计算
        If rs.IndexOf("月") > -1 Then
         If rs.IndexOf("年") > -1 Then
        rs = rs.Split("年")(1)              
        End If 
        rs = rs.Split("月")(0)
        dr!BDM = CInt(rs)
        End If 
        End If
        End If

【知道原因:If rs.IndexOf("月") > -1 Then 右侧括号及双引号是大写状态,故乱,改一下就正常了图片点击可在新窗口打开查看
[此贴子已经被作者于2022/4/30 1:34:46编辑过]

--  作者:有点酸
--  发布时间:2022/4/30 6:07:00
--  
记住一点,新版字符串左右两侧的双引号,必须半角,全角不行的。

其实很好区分,因为字符串是棕色的,如果有一个符号不对,字符串的范围就不对了,也就是可能有一大块棕色出现,而不仅仅是字符串本身。

新输入的代码会自动转转全角半角,主要是复制粘贴代码,才有这个问题。

--  作者:kylin
--  发布时间:2022/4/30 11:57:00
--  
谢谢