Foxtable(狐表)用户栏目专家坐堂 → 请教问题


  共有2302人关注过本帖树形打印复制链接

主题:请教问题

帅哥哟,离线,有人找我吗?
BG小白
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:603 积分:4090 威望:0 精华:0 注册:2019/11/14 23:06:00
请教问题  发帖心情 Post By:2020/6/3 18:28:00 [只看该作者]

If e.KeyCode = keys.Enter Then
    Dim title As WinForm.TextBox = e.Form.Controls("title")
    Dim s As String = title.Text
    Dim r As DataRow = DataTables("GB").AddNew()
    r("SPDM") = s.SubString(0,7)
    r("GG1DM") = s.SubString(7,2)
    r("GG2DM") = s.SubString(9,2)
    r("sl") = 1
    r.save()
    e.Cancel = True
    title.SelectAll
End If
输入不到11位的时候会提示图片1
图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
y2287958
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:4648 积分:33890 威望:0 精华:0 注册:2008/8/31 22:44:00
  发帖心情 Post By:2020/6/3 21:01:00 [只看该作者]

判断一下字符的长度再执行后续代码

 回到顶部
帅哥哟,离线,有人找我吗?
BG小白
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:603 积分:4090 威望:0 精华:0 注册:2019/11/14 23:06:00
  发帖心情 Post By:2020/6/4 0:17:00 [只看该作者]

If e.KeyCode = keys.Enter Then
    Dim title As WinForm.TextBox = e.Form.Controls("title")
    Dim s As String = title.Text
    Dim r As DataRow = DataTables("GB").AddNew
    If s.Length > 11 这里只能大于不能写<>不然就提示错误
                MessageBox.Show("货号输入错误","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        r("SPDM") = s.SubString(0,7)
        If s.Length > 11
            r("GG1DM") = s.SubString(7,2)
            If s.Length > 11
                r("GG2DM") = s.SubString(9,2)
                r.save()
                e.Cancel = True
                title.SelectAll
            End If
        End If
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107680 积分:547721 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/6/4 9:10:00 [只看该作者]

If e.KeyCode = keys.Enter Then
        Dim title As WinForm.TextBox = e.Form.Controls("title")
    Dim s As String = title.Text
    If s.Length <> 11 
        MessageBox.Show("货号输入错误","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Return
    End If

    Dim r As DataRow = DataTables("GB").AddNew
    r("SPDM") = s.SubString(0,7)
    r("GG1DM") = s.SubString(7,2)
    r("GG2DM") = s.SubString(9,2)
    r.save()
    e.Cancel = True
    title.SelectAll
    
End If

 回到顶部