好文档 - 专业文书写作范文服务资料分享网站

VB实例源码 

天下 分享 时间: 加入收藏 我要投稿 点赞

End If

If Combo1.Text = \

MsgBox \请选择货源地!\ Combo1.SetFocus Exit Sub End If

If comboy.Text = \

MsgBox \请选择年份!\ comboy.SetFocus Exit Sub End If

If combom.Text = \

MsgBox \请选择月份!\ combom.SetFocus Exit Sub End If

If combod.Text = \

MsgBox \请选择日期!\ combod.SetFocus Exit Sub End If

If Text2.Text = \

MsgBox \请填写凭证号!\ Text2.SetFocus Exit Sub End If

If Text3.Text = \

MsgBox \请填写经手人!\ Text3.SetFocus Exit Sub End If

If MSFlexGrid1.Col <> 0 Then

MsgBox \请输入完整的物品信息!\ MSFlexGrid1.SetFocus Exit Sub End If

sql = \出入库 where 货单号='\rs_save.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_save.EOF Then rs_save.AddNew

rs_save.Fields(0) = Trim(Text1.Text)

rs_save.Fields(1) = CDate(Trim(comboy.Text) & \& Trim(combom.Text) & \& Trim(combod.Text))

rs_save.Fields(2) = Trim(Combo1.Text)

46

rs_save.Fields(3) = Trim(Text2.Text) rs_save.Fields(4) = Trim(Text3.Text) rs_save.Fields(5) = Trim(Text4.Text)

If crk1.Caption = \入库\ '出入库标记 rs_save.Fields(6) = True Else

rs_save.Fields(6) = False End If

rs_save.Update rs_save.Close Else

MsgBox \货单号重复!\ Text1.SetFocus Text1.Text = \ rs_save.Close Exit Sub End If

sql = \货物明细\

rs_save.Open sql, conn, adOpenKeyset, adLockPessimistic For i = 1 To MSFlexGrid1.Row - 1 rs_save.AddNew

rs_save.Fields(0) = Trim(Text1.Text)

rs_save.Fields(1) = CDate(Trim(comboy.Text) & \& Trim(combom.Text) & \& Trim(combod.Text))

rs_save.Fields(2) = Trim(Combo1.Text) MSFlexGrid1.Row = i MSFlexGrid1.Col = 0

rs_save.Fields(3) = Trim(MSFlexGrid1.Text) MSFlexGrid1.Col = 1

If crk1.Caption = \出库\

s = \ rs_save.Fields(4) = CDbl(s) Else

rs_save.Fields(4) = CDbl(Trim(MSFlexGrid1.Text)) End If

MSFlexGrid1.Col = 2

rs_save.Fields(5) = Trim(MSFlexGrid1.Text) MSFlexGrid1.Col = 3

rs_save.Fields(6) = Trim(MSFlexGrid1.Text) MSFlexGrid1.Col = 4

If crk1.Caption = \出库\

s = \ rs_save.Fields(7) = CDbl(s) Else

47

rs_save.Fields(7) = CDbl(Trim(MSFlexGrid1.Text)) End If

MSFlexGrid1.Col = 5

rs_save.Fields(8) = Trim(MSFlexGrid1.Text) Next i

rs_save.Update rs_save.Close

MsgBox \添加成功!\Unload Me Exit Sub saveerror:

MsgBox Err.Description End Sub

Private Sub Command2_Click() Unload Me End Sub

Private Sub Form_Load() Dim sql As String Dim i As Integer

On Error GoTo loaderror Combo1.AddItem (\北京\Combo1.AddItem (\上海\Combo1.AddItem (\天津\Combo1.AddItem (\武汉\Combo1.AddItem (\广州\Combo1.AddItem (\南京\Combo2.AddItem (\微利公司\Combo2.AddItem (\火星公司\Combo2.AddItem (\南山公司\Combo2.AddItem (\长虹公司\Combo2.AddItem (\利得公司\

For i = 2007 To 2020 comboy.AddItem i Next i

For i = 1 To 12 combom.AddItem i Next i

For i = 1 To 31 combod.AddItem i Next i setgrid

setgrid_head

'添加月份'添加月份 '添加日期 48

Text5.Visible = False clear_grid Exit Sub loaderror:

MsgBox Err.Description End Sub

Private Sub Form_Unload(Cancel As Integer) '关闭数据对象

'rs_checkname.Close 'rs_custom.Close End Sub

Public Sub setgrid() '设置表格子程序 Dim i As Integer

On Error GoTo seterror

MSFlexGrid1.ScrollBars = flexScrollBarBoth MSFlexGrid1.FixedCols = 0 MSFlexGrid1.Rows = row_num MSFlexGrid1.Cols = col_num

MSFlexGrid1.SelectionMode = flexSelectionByRow For i = 0 To row_num - 1

MSFlexGrid1.RowHeight(i) = 315 Next

For i = 0 To col_num - 1

MSFlexGrid1.ColWidth(i) = 1300 Next i Exit Sub seterror:

MsgBox Err.Description End Sub

Public Sub setgrid_head() On Error GoTo setheaderror MSFlexGrid1.Row = 0 MSFlexGrid1.Col = 0

MSFlexGrid1.Text = \物品名称\MSFlexGrid1.Col = 1

MSFlexGrid1.Text = \ 单价\MSFlexGrid1.Col = 2

MSFlexGrid1.Text = \数量\MSFlexGrid1.Col = 3

MSFlexGrid1.Text = \单位\MSFlexGrid1.Col = 4

MSFlexGrid1.Text = \ 金额\MSFlexGrid1.Col = 5

49

MSFlexGrid1.Text = \客户名\Exit Sub setheaderror:

MsgBox Err.Description End Sub

Public Sub clear_grid()

Dim i As Integer, j As Integer For i = 1 To row_num - 1 MSFlexGrid1.Row = i For j = 0 To col_num - 1 MSFlexGrid1.Col = j MSFlexGrid1.Text = \ Next j Next i End Sub

Public Sub nextposition(ByVal r As Integer, ByVal c As Integer) On Error GoTo nexterror

Text5.Width = MSFlexGrid1.CellWidth Text5.Height = MSFlexGrid1.CellHeight

Text5.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(c) Text5.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(r) Text5.Text = MSFlexGrid1.Text Text5.Visible = True Text5.SetFocus Exit Sub nexterror:

MsgBox Err.Description End Sub

Private Sub MSFlexGrid1_Click() If Combo2.Visible = True Then Exit Sub End If

nextposition MSFlexGrid1.Row, MSFlexGrid1.Col End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer) Dim i As Integer, j As Integer

Dim price As Double, coun As Integer On Error GoTo texterror If KeyAscii = 13 Then

MSFlexGrid1.Text = Text5.Text

50

VB实例源码 

EndIfIfCombo1.Text=\MsgBox\请选择货源地!\Combo1.SetFocusExitSubEndIfIfcomboy.Text=\MsgBox\请选择年份!\comboy.SetFocusExitSubEndIfIfcom
推荐度:
点击下载文档文档为doc格式
0rosj0d4ij47hq710ehk
领取福利

微信扫码领取福利

微信扫码分享