Dim cmdtxt As String
cmdtxt = "insert into fenghuashuju (f_name,f_sex,f_minzhu,f_chusheng,f_shenfz) values (" & "'" & txb1.Text & "'" & "," & "'" & txb2.Text & "'" & "," & "'" & txb4.Text & "'" & "," & "'" & txb3.Text & "'" & "," & "'" & txb5.Text & "'" & ")"有什么优化方法没,主要是減少 & 和 ""

解决方案 »

  1.   

    Dim   cmdtxt   As   String 
    cmdtxt   =   "insert   into   fenghuashuju   (f_name,f_sex,f_minzhu,f_chusheng,f_shenfz)   values   ('"   &   txb1.Text   &   "','"   &   txb2.Text   &   "','"   &   txb4.Text   &   "','"   &   txb3.Text   &   "','"   &   txb5.Text   &   "')" 
      

  2.   

    Dim cmdtxt As String 
    cmdtxt = "insert into fenghuashuju (f_name,f_sex,f_minzhu,f_chusheng,f_shenfz) values ('" & txb1.Text & "','" & txb2.Text & "','" & txb4.Text & "','" & txb3.Text & "','" & txb5.Text & "')" 
      

  3.   

    your string
    Dim cmdtxt As String 
    cmdtxt = "insert into fenghuashuju (f_name,f_sex,f_minzhu,f_chusheng,f_shenfz) values (" & "'" & txb1.Text & "'" & "," & "'" & txb2.Text & "'" & "," & "'" & txb4.Text & "'" & "," & "'" & txb3.Text & "'" & "," & "'" & txb5.Text & "'" & ")" removed some "&"
    Dim cmdtxt As String 
    cmdtxt = "insert into fenghuashuju (f_name,f_sex,f_minzhu,f_chusheng,f_shenfz) values ('" & txb1.Text & "','" & txb2.Text & "','" & txb4.Text & "','" & txb3.Text & "','" & txb5.Text & "')" format with _
    Dim cmdtxt As String 
    cmdtxt = "insert into fenghuashuju (f_name,f_sex,f_minzhu,f_chusheng,f_shenfz) values ('" _
    & txb1.Text & "','" _
    & txb2.Text & "','" _
    & txb4.Text & "','" _
    & txb3.Text & "','" _
    & txb5.Text & "')"