7,763
社区成员
发帖
与我相关
我的任务
分享
private sub cmdAdd_Click()
dim sCorporation as string
if frmCorpEdit.Action(sCorporation) then
combo1.add sCorporation '新公司添加到 ComboBox
end if
end if
private sub cmdEdit_Click()
if combo1.text = "" then exit sub
frmCorpEdit.Action combo1.text
end if
Option Explicit
private m_Result as boolean
private m_Corporation as string
public function Action(byref sCorporation as string) as boolean
m_Result = false
m_Corporation = sCorporation
load me
if sCorporation = "" then
新增状态,留空
else
编辑状态,按 sCorporation 读取记录并显示
txtCorporation = sCorporation
txtCorporation.Enabled = False
end if
me.show vbModal
sCorporation = m_Corporation
Action = m_result
end function
private sub cmdOK_click()
if m_Corporation = "" then
做 INSERT
else
做 UPDATE
end if
m_Corporation = txtCorporation
m_Result = true
unload me
end sub
private AddOrEdit as string
public sub Set_State(byval s_State as string)
on error goto err
AddOrEdit = s_State
exit sub
err:
end sub
private sub cmdEdit_click()
dim newfrm as frmCompany
newfrm.set_state "Edit"
set newfrm = nothing
end sub
private sub cmdAdd_click()
dim newfrm as frmCompany
newfrm.set_state "Add"
set newfrm = nothing
end sub
private sub Form_Load()
select case AddOrEdit
'注意大小写
case "Add"
call Init_Ctrl
case "Edit"
call Init_Company
end select
private sub Init_Company()
'根据编辑时传递来的内容初始化
end sub
private sub Init_Ctrl()
'防止控件含有垃圾数据,初始化控件
end sub