九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
如何用VB6控制Excel處理數(shù)據(jù)?
 

數(shù)據(jù)輸入控件:TextDataNum(數(shù)據(jù)組數(shù)輸入TextBox),TextFacNum(參數(shù)個數(shù)輸入TextBox),TextInput(實驗數(shù)據(jù)輸入中介TextBox),GridIn(實驗數(shù)據(jù)表格MSFlexGrid);  
結(jié)果輸出控件:LabTRV(回歸相關(guān)系數(shù)顯示Label),LabTEV(回歸總體方差顯示Label),GridOut(各參數(shù)回歸系數(shù)、標準誤差顯示表格MSFlexGrid);  
程序控制控件:ComCalcu(程序執(zhí)行按鈕CommandButton);  
其它控件從略。  
二、操作步驟  
操作步驟簡述如下:  
1、引用Microsoft   Excel類型庫  
“工程”-“引用”-選擇“Microsoft   Excel   8.0   Object   Library”-“確定”  
2、聲明顯式數(shù)據(jù)類型,創(chuàng)建新實例并獲取Excel的控制句柄  
Dim   ExcelObject   As   Excel.Application  
Set   ExcelObject   =   CreateObject( "Excel.Application ")  
3、調(diào)用并顯示Excel  
Excelobject.Visible   =   True  
由于Excel啟動為不可見,在編程調(diào)試過程中,需要監(jiān)測之,完工后最好Rem。  
4、將GridIn中的數(shù)據(jù)送入Excel  
5、Excel對數(shù)據(jù)進行多元回歸  
6、將Excel運算結(jié)果輸入GridOut,LabTRV   和LabTEV  
7、最后交還Excel控制句柄  
Set   ExcelObject   =   Nothing  
此方法也可直接控制其他大量應用軟件,可從你的Object   Library略知一二。  
三、操作程序  
部分源程序代碼如下:  
通用聲明  
Dim   DNum   As   Integer   '   DNum數(shù)據(jù)組數(shù)  
Dim   FNum   As   Integer   '   FNum參數(shù)個數(shù)  
Dim   ExcelObject   As   Excel.Application  
表格初始化  
--DataGRidMK   'GridIn制作模塊  
Sub   DataGRidMK()    
DNum   =   Val(Me.TextDataNum.Text)  
FNum   =   Val(Me.TextFacNum.Text)  
With   Me.GridIn  
.Cols   =   FNum   +   2  
.Rows   =   DNum   +   1  
End   With  
With   Me.GridIn  
.Row   =   0  
.Col   =   0:   .Text   =   "   實驗數(shù)據(jù) "  
.Col   =   1:   .Text   =   "   測值Y "  
For   i   =   1   To   .Cols   -   1  
.ColWidth(i)   =   1200  
Next   i  
For   i   =   2   To   .Cols   -   1  
.Col   =   i  
.Text   =   "   參數(shù)   X "   &   (i   -   1)  
Next   i  
For   i   =   1   To   .Rows   -   1  
.Col   =   0  
.Row   =   i:   .Text   =   "   "   &   i  
Next   i  
End   With  
End   Sub  
--DataInitial   '隨機產(chǎn)生GridIn數(shù)據(jù)模塊  
Sub   DataInitial()   '隨機產(chǎn)生表格數(shù)據(jù)  
Randomize   Timer  
With   Me.GridIn  
For   i   =   1   To   .Rows   -   1  
.Row   =   i  
For   j   =   1   To   .Cols   -   1  
.Col   =   j  
.Text   =   Rnd   *   500   \   1  
Next   j  
Next   i  
End   With  
End   Sub    
為方便程序調(diào)式,實驗數(shù)據(jù)采用隨機產(chǎn)生;也可自行修改/輸入,從略  
--GridOutMK   'GridOut制作模塊  
Sub   GridOutMK()  
With   Me.GridOut  
.Cols   =   FNum   +   2  
.Rows   =   3  
End   With  
With   Me.GridOut  
.Row   =   0  
.Col   =   0:   .Text   =   "   回歸輸出 "  
.Col   =   1:   .Text   =   "   Const "  
.Row   =   1:   .Col   =   0:   .Text   =   "   系數(shù)Ai "  
.Row   =   2:   .Col   =   0:   .Text   =   "   相關(guān)系數(shù) "  
For   i   =   1   To   .Cols   -   1  
.ColWidth(i)   =   1200  
Next   i  
.Row   =   0  
For   i   =   2   To   .Cols   -   1  
.Col   =   i  
.Text   =   "   參數(shù)   X "   &   (i   -   1)  
Next   i  
End   With  
End   Sub  
回歸運算  
Private   Sub   ComCalcu_Click()  
'   GridOut清空  
With   Me.GridOut  
For   i   =   1   To   .Rows   -   1  
.Row   =   i  
For   j   =   1   To   .Cols   -   1  
.Col   =   j  
.Text   =   " "  
Next   j  
Next   i  
End   With  
'LabTEV,LabTRV處于等待狀態(tài)  
With   Me.LabTEV  
.BackColor   =   vbBlue  
End   With  
With   Me.LabTRV  
.BackColor   =   vbBlue  
End   With  
    
Dim   SA   As   String,   Sb$,   Sc$  
Set   ExcelObject   =   CreateObject( "Excel.Application ")   '創(chuàng)建新實例  
'Excelobject.Visible   =   True   '顯示調(diào)用  
ExcelObject.Workbooks.Add   '添加新工作簿  
Sb   =   "B "   &   Format$(DNum)  
Sc   =   Chr$(65   +   FNum)   &   Format$(DNum)  
'表格數(shù)據(jù)送入Excel  
For   i   =   1   To   DNum  
Me.GridIn.Row   =   i  
For   j   =   1   To   FNum   +   1  
Me.GridIn.Col   =   j  
If   Me.GridIn.Text   =   " "   Then  
MsgBox   "實驗數(shù)據(jù)有空缺,請補充完整。 ",   vbOKOnly,   "警告 "  
With   Me.LabTEV  
.Caption   =   "#VALUE "  
.BackColor   =   &HC0C0C0  
End   With  
With   Me.LabTRV  
.Caption   =   "#VALUE "  
.BackColor   =   &HC0C0C0  
End   With  
'Set   Excelobject   =   Nothing  
Exit   Sub  
End   If  
SA   =   Chr$(64   +   j)   &   Format$(i)  
ExcelObject.Range(SA).Value   =   Me.GridIn.Text  
Next   j  
Next   i  
'回歸運算  
Dim   Ip,   P   As   String   '定位回歸結(jié)果顯示單元格  
For   i   =   1   To   2  
Ip   =   Format$(i   +   DNum)   'i=1時在第Dnum+1行顯示系數(shù),i=2時在第Dnum+2行   顯示標準誤差  
For   j   =   1   To   FNum   +   1  
P   =   Chr$(64   +   j)   &   Ip  
ExcelObject.Range(P).Formula= "=INDEX(LINEST($A$1:$A$ "&   Format$(DNum)    
&   ",$B$1:$ "   &   Chr$(65   +   FNum)   &   "$ "   &   Format$(DNum)   &   ",1,1), "   &    
Format$(i)   &   ", "   &   Format$(j)   &   ") "  
Next   j  
Next   i  
P   =   "A "   &   Format$(DNum   +   3)   '定位  
ExcelObject.Range(P).Formula   =   "=INDEX(LINEST($A$1:$A$ "   &   Format$(DNum)   &   ",$B$1:$ "   &   Chr$(65   +   FNum)   &   "$ "   &   Format$(DNum)   &   ",1,1),3,1) "   '相關(guān)系數(shù)  
P   =   "B "   &   Format$(DNum   +   3)   '定位  
ExcelObject.Range(P).Formula   =   "=INDEX(LINEST($A$1:$A$ "   &   Format$(DNum)   &   ",$B$1:$ "   &   Chr$(65   +   FNum)   &   "$ "   &   Format$(DNum)   &   ",1,1),3,2) "   '總體方差  
    
'顯示回歸結(jié)果至GridOut  
With   Me.GridOut  
'顯示Const系數(shù)  
.Row   =   1:   .Col   =   1  
P   =   Chr$(64   +   FNum   +   1)   &   Format$(DNum   +   1)  
.Text   =   Format$(ExcelObject.Range(P).Value,   "0.0000 ")  
'顯示Const標準誤差  
.Row   =   2:   .Col   =   1  
P   =   Chr$(64   +   FNum   +   1)   &   Format$(DNum   +   2)  
.Text   =   Format$(ExcelObject.Range(P).Value,   "0.0000 ")  
For   i   =   1   To   FNum  
'顯示系數(shù)  
.Row   =   1  
P   =   Chr$(64   +   i)   &   Format$(DNum   +   1)  
.Col   =   FNum   -   i   +   2  
.Text   =   Format$(ExcelObject.Range(P).Value,   "0.0000 ")  
'顯示標準誤差  
.Row   =   2  
P   =   Chr$(64   +   i)   &   Format$(DNum   +   2)  
.Col   =   FNum   -   i   +   2  
.Text   =   Format$(ExcelObject.Range(P).Value,   "0.0000 ")  
Next   i  
End   With  
'顯示總體相關(guān)系數(shù)  
P   =   "A "   &   Format$(DNum   +   3)  
Me.LabTRV.Caption   =   Format$(ExcelObject.Range(P).Value,   "0.0000 ")  
'顯示總體方差  
P   =   "B "   &   Format$(DNum   +   3)  
Me.LabTEV.Caption   =   Format$(ExcelObject.Range(P).Value,   "0.0000 ")  
    
With   Me.LabTEV  
.BackColor   =   &HC0C0C0  
End   With  
With   Me.LabTRV  
.BackColor   =   &HC0C0C0  
End   With  
Set   ExcelObject   =   Nothing  
End   Sub  
說明:Excel回歸結(jié)果“矩陣”(記為A())與一般的思維相異,以三元回歸為例,A(1,1)和A(2,1)分別為X3的回歸系數(shù)和標準誤差,A(1,2)和A(2,2)對應X2,A(1,3)和A(2,3)對應X1,A(1,4)和A(2,4)對應常數(shù)項,A(3,1)代表回歸相關(guān)系數(shù),A(3,1)代表回歸總體方差。  
本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
關(guān)于 VFP 輸出 EXCEL 的格式
Excel VBA中讀取Access數(shù)據(jù)庫表時只取日期的辦法
Python 操作Excel文件 (十五)
python XlsxWriter模塊創(chuàng)建aexcel表格
python處理excel文件之xlsxwriter 模塊
自動化辦公:python操作Excel
更多類似文章 >>
生活服務
熱點新聞
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服