以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何判断变量取的是空值?谢谢  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=3706)

--  作者:杨浩
--  发布时间:2009/7/27 11:04:00
--  如何判断变量取的是空值?谢谢

 

Dim dlg As New SaveFileDialog   \'指定一个新的SaveFileDialog
dlg.Filter= "
下发文件|*.XF"   \'设置筛选器
dlg.OverwritePrompt = True
 \'对于已经存在的文件名,是否出现覆盖警告

If dlg.ShowDialog = DialogResult.Ok Then   \'如果用户单击了确定按钮

If FileSys.FileExists(dlg.filename) Then    \'如果指定的文件存在
   
FileSys.DeleteFile(dlg.filename,2,2)     \'则彻底删除之
    End If
   
Dim aa As string

aa = e.Form.Controls("单位名称").Value

if aa =  " " then

 MessageBox.Show("你未选择需要下发数据的单位,选择单位以后才能生成下发数据!!!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)

Return       \'终止代码的执行

End If

Else

Dim ex as New Exporter
    ex.SourceTableName = "
调资基础数据"   \'指定导出表 

ex.Filter = "[单位名称] = \'" & aa & "\'" \'指定导出条件

ex.Format = "Access"   \'指定导出文件格式
    ex. PassWord = “TZX_GWY_JT_8888”  \'用此属性指定目标文件的密码

ex.filepath =  dlg.filename    \'指定目标文件

ex.NewTableName = "调资基础数据"        \'指定导出后的表的名称

    ex.Export()    \'开始导出数据
   MessageBox.Show( "下发" & aa & "单位数据生成完成!!!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)

End If


--  作者:杨浩
--  发布时间:2009/7/27 11:05:00
--  
当没有选择单位时提示“没有选择单位,无法生成下发数据!!!”

if aa =  " " then

 MessageBox.Show("你未选择需要下发数据的单位,选择单位以后才能生成下发数据!!!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)

Return       \'终止代码的执行


--  作者:杨浩
--  发布时间:2009/7/27 11:07:00
--  
版主看看,谢谢
--  作者:yangming
--  发布时间:2009/7/27 11:13:00
--  
注意红色部分与你代码的不同

Dim aa As string
aa = e.Form.Controls("ComboBox1").Value
if aa = "" then
 MessageBox.Show("你未选择需要下发数据的单位,选择单位以后才能生成下发数据!!!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)
Return       \'终止代码的执行
Else

Dim ex as New Exporter
    ex.SourceTableName = "调资基础数据"   \'指定导出表 

ex.Filter = "[单位名称] = \'" & aa & "\'" \'指定导出条件

ex.Format = "Access"   \'指定导出文件格式
    ex. PassWord = “TZX_GWY_JT_8888”  \'用此属性指定目标文件的密码

ex.filepath =  dlg.filename    \'指定目标文件

ex.NewTableName = "调资基础数据"        \'指定导出后的表的名称

    ex.Export()    \'开始导出数据
   MessageBox.Show( "下发" & aa & "单位数据生成完成!!!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)

End If


[此贴子已经被作者于2009-7-27 11:14:36编辑过]

--  作者:杨浩
--  发布时间:2009/7/27 11:35:00
--  
Dim aa As string
aa = e.Form.Controls("单位名称").Value
if aa = "" then
 MessageBox.Show("你未选择需要下发数据的单位,选择单位以后才能生成下发数据!!!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)
Return       \'终止代码的执行
Else
End If
Dim dlg As New SaveFileDialog   \'指定一个新的SaveFileDialog
dlg.Filter= "下发文件|*.DXF"   \'设置筛选器
dlg. title= "下发指定单位数据"
dlg.OverwritePrompt = True  \'对于已经存在的文件名,是否出现覆盖警告
If dlg.ShowDialog = DialogResult.Ok Then   \'如果用户单击了确定按钮
If FileSys.FileExists(dlg.filename) Then    \'如果指定的文件存在
    FileSys.DeleteFile(dlg.filename,2,2)     \'则彻底删除之
    End If
Dim ex as New Exporter
    ex.SourceTableName = "调资基础数据"   \'指定导出表 
ex.Filter = "[单位名称] = \'" & aa & "\'" \'指定导出条件
ex.Format = "Access"   \'指定导出文件格式
    ex. PassWord = "TZX_GWY_JT_8888"  \'用此属性指定目标文件的密码
ex.filepath =  dlg.filename    \'指定目标文件
ex.NewTableName = "调资基础数据"        \'指定导出后的表的名称
    ex.Export()    \'开始导出数据
   MessageBox.Show( "下发" & aa & "单位数据生成完成!!!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information)
  Dim cmb As WinForm.comboBox = e.Form.Controls("单位名称")
  cmb.value=""
End If

--  作者:杨浩
--  发布时间:2009/7/27 11:35:00
--  
我是这样改的,可以实现了!!!谢谢