当前位置:编程学习 > VB >>

VB调用外部函数时,总提示应用程序错误

这是VB声明 
Public Declare Function f_outp_unregister Lib "ProxyDll.dll" (ByVal qe As String) As Long '注册函数 
Public Declare Function f_outp_affirm Lib "ProxyDll.dll" (ByVal qb As String) As Long ‘交费函数 
Public Declare Function f_outp_divide Lib "ProxyDll.dll" (ByVal qj As String, ByVal dq As String) As Long '获得费用分解信息 
下面是执行时的源代码 

  
        Dim sc_in As String                                            '定义上传生成*.in文件 
        Dim sc_out As String 
        Dim szreturn As Long 
                                                                        '定义上传门诊注册号 
        Dim sc As String 
        Dim sc1 As String 
        Dim sc2 As String 
        Dim sc4 As String 
        Dim sc3 As Long 
                                                                        '定义从卡内减金额 
        Dim j_money As String 
        Dim j_money1 As String 
        Dim j_money2 As String 
        Dim j_money3 As Long 
        
        Dim d1 As Integer 
        Dim i As Integer 
        Dim sum_count As Integer                                                                '定义连接数据源 
        

                                                                        '设置数据源 
        
        
        Dim newcnn As String 
        Dim sql As String 
        Set cnn = New ADODB.Connection 
        newcnn = "DSN=Tdyyhospital" 
        cnn.Open newcnn 
        
        sc = Txt_prespriceID.Text                                      '门诊流水号 
        sc1 = Label4.Caption                                            '社保号 
        sc2 = Format(DTPicker1.Value, "yyyymmdd")                      '用药日期 
        sc4 = sc + "|" + sc1 + "|" + sc2 + "|" + ""                    '上传文件 
        sc3 = f_outp_register(sc4)                                      '调用函数 
        If sc3 = 0 Then                                                '注册门诊号成功 
            MsgBox "已成功注册门诊号!!", 64, "系统提示" 
            sql = "delete from 门诊检查处方临时表 "                    '删除临时处方表 
            cnn.Execute sql 
            
            Adodc8.RecordSource = "select * from  mzjccf  where cfid ='" + Txt_prespriceID.Text + "'and hjzt = '0'" '向库内添加数据 
            Adodc8.Refresh 
            If Adodc8.Recordset.RecordCount > 0 Then                    '汇总此次处方总记录数 
                sum_count = Adodc8.Recordset.RecordCount 
            End If 
            Adodc8.Recordset.Close 
                          
                                                                        '生成给医保提交的.in文件 
            Adodc8.RecordSource = "select * from  mzjccf  where cfid ='" + Txt_prespriceID.Text + "'and hjzt = '0'" '向库内添加数据 
            Adodc8.Refresh 
            Open "D:\2.in " For Output As #1                            ' 打开输出文件。 
            Print #1, Adodc8.Recordset.Fields("cfid"); "|"; Adodc8.Recordset.Fields("cfid"); "|"; Label4.Caption; "|"; Format(Adodc8.Recordset.Fields("kfdate"), "yyyymmdd"); "|"; "0|||"; "|"; Format(sum_count, "0"); "|"; Format(Label19.Caption, "0.00") 
            For i = 0 To Adodc8.Recordset.RecordCount - 1 
                Print #1, Adodc8.Recordset.Fields("xmdm"); "|"; Adodc8.Recordset.Fields("jcxmmc"); "|"; Adodc8.Recordset.Fields("dw"); "|"; Format(Adodc8.Recordset.Fields("dj"), "0.00"); "|"; Format(Adodc8.Recordset.Fields("dw"), ""); "|"; Format(Adodc8.Recordset.Fields("sl"), ""); "|"; Format(Adodc8.Recordset.Fields("hjje"), "0.00"); "|"; Format(Adodc8.Recordset.Fields("dw"), ""); "|"; Format(Adodc8.Recordset.Fields("gg"), "") 
                Adodc8.Recordset.MoveNext 
            Next i 
            Close #1                                                    ' 关闭文件。 
            Adodc8.Recordset.Close 
            
            sc_in = "d:\2.in" 
            sc_out = "d:\2.out" 
            szreturn = f_outp_divide(sc_in, sc_out)                    '开始上传 
            
            If szreturn = 0 Then                                        '上传文件成功开始减金额 
                
                j_money = Txt_prespriceID.Text                          '取门诊号 
                j_money1 = Label4.Caption                              '取社保号 
                j_money2 = j_money + "|" + j_money + "|" + j_money1    '上传文件 
                j_money3 = f_outp_affirm(j_money2)                      '调用函数划价从患者卡内减金钱 
                If j_money3 = 0 Then                                    '减金额成功 
                                                                        '开始划价 
                    Adodc8.RecordSource = "select * from  mzjccf  where cfid ='" + Txt_prespriceID.Text + "'and hjzt = '0'" '向库内添加数据 
                    Adodc8.Refresh 
                    If Adodc8.Recordset.RecordCount > 0 Then 
                        Adodc8.Recordset.MoveFirst 
                        For d1 = 0 To Adodc8.Recordset.RecordCount - 1 
                            Adodc8.Recordset.Fields("hjzt") = "1" 
                            Adodc8.Recordset.Fields("ybkh") = Label4.Caption 
                            Adodc8.Recordset.Fields("hzkh") = Trim(Text2.Text) 
                            Adodc8.Recordset.Fields("sky") = Frm_main.StatusBar1.Panels(3).Text 
                            Adodc8.Recordset.Fields("pat_lb") = "医保" 
                            Adodc8.Recordset.Update 
                            Adodc8.Recordset.MoveNext 
                        Next d1 
                    End If 
                    
                    Adodc3.RecordSource = "select * from 门诊检查处方临时表" 
                    Adodc3.Refresh 
                    
                    
                    Cmd_save.Enabled = False 
                    Cmd_print.Enabled = True 
                    Adodc8.Recordset.Close 
                    
                    Adodc8.RecordSource = "select sum(hjje)as 总金额为,sum(zfbl)as部为,sum(ybzf)as为 from mzjccf where cfid ='" + Txt_prespriceID.Text + "'" 
                    Adodc8.Refresh 
                    If Adodc8.Recordset.Fields(0) <> "" Then 
                        Label19.Caption = Format(Adodc8.Recordset.Fields(0), "0.00") 
                    Else 
                        Label19.Caption = "0.00" 
                    End If 
                            
                    If Adodc8.Recordset.Fields(1) <> "" Then 
                        Label22.Caption = Format(Adodc8.Recordset.Fields(1), "0.00") 
                    Else 
                        Label22.Caption = "0.00" 
                    End If 
                            
                    If Adodc8.Recordset.Fields(2) <> "" Then 
                        Label5.Caption = Format(Adodc8.Recordset.Fields(2), "0.00") 
                    Else 
                        Label5.Caption = "0.00" 
                    End If 
                    MsgBox "已经保存成功上传!!", 64, "系统提示" 
                    Cmd_read_card.Enabled = True 

                    Txt_code.Enabled = True 
                    Txt_code.Visible = True
执行上面的代码时,总是提示应用程序错误,。程序就非法退出了?????
补充:VB ,  资源
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,