Foxtable(狐表)用户栏目专家坐堂 → 判断字符串是否包含星号,如果有星号则进行分割填充,代码怎么写?


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

主题:判断字符串是否包含星号,如果有星号则进行分割填充,代码怎么写?

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


加好友 发短信
等级:二尾狐 帖子:532 积分:4020 威望:0 精华:0 注册:2011/6/18 12:41:00
判断字符串是否包含星号,如果有星号则进行分割填充,代码怎么写?  发帖心情 Post By:2020/2/23 17:33:00 [只看该作者]



如图,当规格包含* 比如20*0.05  那么自动分割和填充 宽度等于20 厚度等于0.05


        如果含有多个只取前面两部分 比如100*0.03*15公斤 那么宽度=100 厚度=0.03


        如果规格不含* 则不填充宽度和厚度。


      代码怎么写啊?


      当规格等于80*100=33G 类似这样的时候会出错,怎么解决?


 



此主题相关图片如下:未标题-2.jpg
按此在新窗口浏览图片



Dim tbl As Table = Tables("吹膜选产品_Table1")
If tbl.Current IsNot Nothing Then



    Tables("chuimo").Current("chanpinid") = tbl.Current("chanpinid")


'分割规格,分别自动填入 宽度 厚度
Dim guige1=tbl.current("guige")
If guige1="" Or guige1.IndexOf("*") = -1 Then
Tables("chuimo").current("kuandu")=""
 Tables("chuimo").current("houdu")=""
Else
Dim s1() As String
s1=guige1.split("*")
Tables("chuimo").current("kuandu")=s1(0)
Tables("chuimo").current("houdu")=s1(1)
End If



End If
Forms("
吹膜选产品").Close()


 


[此贴子已经被作者于2020/3/5 16:39:29编辑过]

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


加好友 发短信
等级:三尾狐 帖子:645 积分:5680 威望:0 精华:0 注册:2017/4/7 12:15:00
  发帖心情 Post By:2020/2/23 18:20:00 [只看该作者]

Tables("chuimo").current("houdu")=s1(1). split("=")(0)

 回到顶部
帅哥,在线噢!
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

Dim guige1  as string = tbl.current("guige")
Dim sps() As Char = {"*","="}
dim s1() As String=guige1.split(sps)
if s1.length > 1 then
Tables("chuimo").current("kuandu")=s1(0)
Tables("chuimo").current("houdu")=s1(1)
else
Tables("chuimo").current("kuandu")=""
 Tables("chuimo").current("houdu")=""
end if
[此贴子已经被作者于2020/2/23 21:59:16编辑过]

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


加好友 发短信
等级:二尾狐 帖子:532 积分:4020 威望:0 精华:0 注册:2011/6/18 12:41:00
  发帖心情 Post By:2020/3/5 11:32:00 [只看该作者]

还是会出错,当选择产品名称 一级红双草绳  规格 8CM 类似这样的格式 会出现以下错误提示:

图片点击可在新窗口打开查看此主题相关图片如下:6.jpg
图片点击可在新窗口打开查看

代码如下:
-----------------------------------------------------------------

吹膜选产品_TextBox1_TextChanged

 

Dim txt As String = e.Form.Controls("TextBox1").Text

Dim tbl As Table = Tables("吹膜选产品_Table1")

tbl.Filter= ""

If txt = "" Then

    tbl.Filter = ""

Else

   txt = "'*" & txt.Replace("*","[*]") & "*'"

    '或者 txt = "'*" & strtowide(txt) & "*'"

 

If txt.IndexOf(" ") = -1 Then '如果没有空格

tbl.filter = "chanpinname Like " & txt & " or guige Like " & txt & " or JM Like " & txt & " "

    tbl.Sort = "chanpinname desc,guige desc,danwei desc"

 

Else

'Dim txt As String

Dim txt2 As String

Dim txt3 As String

Dim Values() As String

Values = txt.split(" ")

txt2=values(0)& "*'"

txt3="'*"& values(1)

 

    tbl.filter = "chanpinname Like " & txt2 & " And guige Like " & txt3 & " "

    tbl.Sort = "chanpinname desc,guige desc,danwei desc"

'Messagebox.show(tbl.filter)

End If

End If





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


加好友 发短信
等级:二尾狐 帖子:532 积分:4020 威望:0 精华:0 注册:2011/6/18 12:41:00
  发帖心情 Post By:2020/3/5 11:33:00 [只看该作者]

-------------------------------------------------------------------

吹膜选产品_TextBox1_KeyDown

 

Dim tbl As Table = Tables("吹膜选产品_Table1")

If e.KeyCode = Keys.Up Then

    tbl.Position = tbl.Position - 1

    e.Cancel = True

ElseIf e.KeyCode = Keys.Down Then

    tbl.Position = tbl.Position + 1

    e.Cancel = True

ElseIf e.KeyCode = Keys.Enter Then

    If tbl.Current IsNot Nothing Then

       ' Tables("chuimo").Current("chanpinname") = tbl.Current("chanpinname")

       ' Tables("chuimo").Current("guige") = tbl.Current("guige")

        'Tables("chuimo").Current("danwei") = tbl.Current("danwei")

        Tables("chuimo").Current("chanpinid") = tbl.Current("chanpinid")

        Tables("chuimo").Current("addtime")= now()

        Tables("chuimo").Current("adduser")= user.name

 

'分割规格,分别自动填入 宽度 厚度

Dim guige1  As String = tbl.current("guige")

Dim sps() As Char = {"*","="}

Dim s1() As String=guige1.split(sps)

If s1.length > 1 Then

Tables("chuimo").current("kuandu")=s1(0)

Tables("chuimo").current("houdu")=s1(1)

Else

Tables("chuimo").current("kuandu")=""

 Tables("chuimo").current("houdu")=""

End If

       

    End If

    e.Cancel = True

    e.Form.Close()

End If



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


加好友 发短信
等级:二尾狐 帖子:532 积分:4020 威望:0 精华:0 注册:2011/6/18 12:41:00
  发帖心情 Post By:2020/3/5 11:33:00 [只看该作者]

-------------------------------------------------------------------------

吹膜选产品_Table1_DoubleClick

 

Dim tbl As Table = Tables("吹膜选产品_Table1")

If tbl.Current IsNot Nothing Then

 

  

    Tables("chuimo").Current("chanpinid") = tbl.Current("chanpinid")

    Tables("chuimo").Current("addtime")= now()

    Tables("chuimo").Current("adduser")= user.name

 

'分割规格,分别自动填入 宽度 厚度

Dim guige1  As String = tbl.current("guige")

Dim sps() As Char = {"*","="}

Dim s1() As String=guige1.split(sps)

If s1.length > 1 Then

Tables("chuimo").current("kuandu")=s1(0)

Tables("chuimo").current("houdu")=s1(1)

Else

Tables("chuimo").current("kuandu")=""

 Tables("chuimo").current("houdu")=""

End If

End If

Forms("吹膜选产品").Close()


----------------------------------------------------------------------


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


加好友 发短信
等级:二尾狐 帖子:532 积分:4020 威望:0 精华:0 注册:2011/6/18 12:41:00
  发帖心情 Post By:2020/3/5 11:33:00 [只看该作者]


吹膜选产品_Table1_KeyDown

 

If e.KeyCode = Keys.Enter Then

    Dim tbl As Table = Tables("吹膜选产品_table1")

    If tbl.Current IsNot Nothing Then

        'Tables("chuimo").Current("chanpinname") = tbl.Current("chanpinname")

    'Tables("chuimo").Current("guige") = tbl.Current("guige")

    'Tables("chuimo").Current("danwei") = tbl.Current("danwei")

    Tables("chuimo").Current("chanpinid") = tbl.Current("chanpinid")

    Tables("chuimo").Current("addtime")= now()

    Tables("chuimo").Current("adduser")= user.name

 

'分割规格,分别自动填入 宽度 厚度

Dim guige1  As String = tbl.current("guige")

Dim sps() As Char = {"*","="}

Dim s1() As String=guige1.split(sps)

If s1.length > 1 Then

Tables("chuimo").current("kuandu")=s1(0)

Tables("chuimo").current("houdu")=s1(1)

Else

Tables("chuimo").current("kuandu")=""

 Tables("chuimo").current("houdu")=""

End If

 

 

    End If

    Forms("吹膜选产品").Close()

End If

 

----------------------------------------------------------------
请问如何解决?


 回到顶部
帅哥,在线噢!
有点蓝
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

勾选4楼图片里的出错窗口的“显示详细信息”,看是哪个事件的问题?

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


加好友 发短信
等级:二尾狐 帖子:532 积分:4020 威望:0 精华:0 注册:2011/6/18 12:41:00
  发帖心情 Post By:2020/3/5 16:43:00 [只看该作者]

 有时候会一直报错 (就是运行这段代码的时候每次都报错。)。直到重启电脑,有时候会报错,有时候不会。

.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2020.1.19.19
错误所在事件:窗口,吹膜选产品,TextBox1,KeyDown
详细错误信息:
从字符串“”到类型“Double”的转换无效。
输入字符串的格式不正确。

[此贴子已经被作者于2020/3/5 16:43:39编辑过]

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


加好友 发短信
等级:二尾狐 帖子:532 积分:4020 威望:0 精华:0 注册:2011/6/18 12:41:00
  发帖心情 Post By:2020/3/5 16:48:00 [只看该作者]

.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2020.1.19.19
错误所在事件:chanpin,KeyDown
详细错误信息:
从字符串“”到类型“Double”的转换无效。
输入字符串的格式不正确。

 回到顶部
总数 11 1 2 下一页