vb.net标准表达式的简单介绍
VB.net 中 标准表达式中数据类型不匹配
数据库中 age 字段,birthday 字段是什么类型?都不是字符型吧。。。
成都创新互联公司是一家专业提供周口企业网站建设,专注与网站建设、成都做网站、成都h5网站建设、小程序制作等业务。10年已为周口众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。
=======================================================
birthday 是数字?不太可能吧。。。难道你不是用来存放生日的!
要真是 数字 你这样写试试
MyCommand = New OleDbCommand("UPDATE yggrxx SET name ='" TextBox2.Text "',sex = '" TextBox3.Text "',age =" TextBox4.Text ",birthday = " val(TextBox5.Text) ", address = '" TextBox6.Text "', postid = " TextBox7.Text ", pwd = '" TextBox8.Text "' where id = " TextBox1.Text, MyConnection)
要是是 日期/时间 你这样写试试
MyCommand = New OleDbCommand("UPDATE yggrxx SET name ='" TextBox2.Text "',sex = '" TextBox3.Text "',age =" TextBox4.Text ",birthday = #" TextBox5.Text "#, address = '" TextBox6.Text "', postid = " TextBox7.Text ", pwd = '" TextBox8.Text "' where id = " TextBox1.Text, MyConnection)
vb.net 标准表达式中数据类型不匹配
VB6中,在使用Select语句的Where子句时:
对于字符型,要用单引号:
Where 字段名=' " 字符型变量 "'"
而对于日期型,要用井字号“#”:
Where 日期型字段名=# " 日期型变量 "#"
对于VB.net,应该是一样的道理,你可以按照VB6试试。
vb.net正则表达式
Imports System.Text.RegularExpressions
Public Class Form1
Public Function MadeRegexArray(ByVal strText As String, ByVal strRegx As String, ByVal rexOpt As RegexOptions, ByVal Groups As Integer) As String()
REM 正则结果直接以字符串组形式返回
REM strHtml待搜索的字符串
REM strRegx正则表达式
REM rexOpt正则选项
On Error Resume Next
Return MadeMatchString(MadeRegexMatch(strText, strRegx, rexOpt), Groups)
End Function
Public Function MadeMatchString(ByVal mc As MatchCollection, ByVal Groups As Integer) As String()
REM 把MatchCollection以字符串组形式保存
REM mc正则匹配的集合
REM 返回字符串组
On Error Resume Next
Dim strRegCode(mc.Count) As String
For i As Integer = 0 To mc.Count - 1
strRegCode(i) = mc(i).Groups(Groups).Value
Next i
Return strRegCode
End Function
Public Function MadeRegexMatch(ByVal strText As String, ByVal strRegex As String, ByVal rexOpt As RegexOptions) As MatchCollection
REM 获取正则表达式匹配的集合
REM strHtml待正则的字符串
REM strRegex正则表达式
REM rexOpt正则选项
REM 返回 MatchCollection 类型集合
On Error Resume Next
Dim rex As Regex = New Regex(strRegex, rexOpt)
Return rex.Matches(strText)
End Function
Public Function MadeRegexReplace(ByVal sText As String, ByVal sRegex As String, ByVal sReplace As String) As String
REM 正则表达式文本替换
REM sText原文本
REM sRegex表达式
REM sReplace替换文本
On Error Resume Next
Dim rex As Regex = New Regex(sRegex, RegexOptions.IgnoreCase)
Return rex.Replace(sText, sReplace)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error Resume Next
Dim sRegex As String = "([\s\S]*?)"
Dim aTable() As String = MadeRegexArray(TextBox1.Text, sRegex, RegexOptions.IgnoreCase, 1)
For i As Integer = 0 To aTable.Length - 1
TextBox2.Text = TextBox2.Text aTable(i)
Next i
End Sub
End Class
如图:
vb.net 正则表达式
正则表达式是:
/[a-zA-Z/]+$
如果要把第一个斜杠去掉,就是匹配index/index/index,用后向匹配,正则是:
(?=/)[a-zA-Z/]+$
标题名称:vb.net标准表达式的简单介绍
浏览路径:http://scyanting.com/article/dopijgg.html