Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1892|回复: 0

vb6中如何调用或模拟excel的函数来做计算

[复制链接]
发表于 2015-1-22 15:21 | 显示全部楼层 |阅读模式
用vb6做了个卡方计算器,就是照着这个网页做的:blog.sina.com.cn/s/blog_974139980100v6ar.ht   ml (去掉空格)

结果发现vb里面没有CHITEST函数,请问如何弄?
另外,我有一个rc.exe小程序想嵌入到我做的软件里,怎么也搞不好,到别人电脑释放不出来,如果会也帮我整一下,或者告诉我步骤和代码也行,谢谢!



附上计算器代码:
Private Sub 计算_Click()
On Error GoTo 1

Text5.Text = Val(Text1.Text) + Val(Text3.Text)
Text6.Text = Val(Text2.Text) + Val(Text4.Text)
Text7.Text = Val(Text1.Text) + Val(Text2.Text)
Text8.Text = Val(Text3.Text) + Val(Text4.Text)
Text9.Text = Val(Text5.Text) + Val(Text6.Text)
Text10.Text = Text5.Text * Text7.Text / Text9.Text
Text11.Text = Text6.Text * Text7.Text / Text9.Text
Text12.Text = Text5.Text * Text8.Text / Text9.Text
Text13.Text = Text6.Text * Text8.Text / Text9.Text
Text14.Text = Val(Text10.Text) + Val(Text12.Text)
Text15.Text = Val(Text11.Text) + Val(Text13.Text)
Text16.Text = Val(Text10.Text) + Val(Text11.Text)
Text17.Text = Val(Text12.Text) + Val(Text13.Text)
Text18.Text = Val(Text14.Text) + Val(Text15.Text)
a = (Val(Text1.Text) - Val(Text10.Text)) * (Val(Text1.Text) - Val(Text10.Text)) / Val(Text10.Text)
b = (Val(Text2.Text) - Val(Text11.Text)) * (Val(Text2.Text) - Val(Text11.Text)) / Val(Text11.Text)
C = (Val(Text3.Text) - Val(Text12.Text)) * (Val(Text3.Text) - Val(Text12.Text)) / Val(Text12.Text)
d = (Val(Text4.Text) - Val(Text13.Text)) * (Val(Text4.Text) - Val(Text13.Text)) / Val(Text13.Text)
Text19.Text = a + b + C + d

Application.WorksheetFunction.range("A1").Value = Val(Text1.Text)
Application.WorksheetFunction.range("b1").Value = Val(Text2.Text)
Application.WorksheetFunction.range("A2").Value = Val(Text3.Text)
Application.WorksheetFunction.range("b2").Value = Val(Text4.Text)
Application.WorksheetFunction.range("A3").Value = Val(Text10.Text)
Application.WorksheetFunction.range("b3").Value = Val(Text11.Text)
Application.WorksheetFunction.range("A4").Value = Val(Text12.Text)
Application.WorksheetFunction.range("b4").Value = Val(Text13.Text)
Text20.Text = Application.WorksheetFunction.CHITeST(Application.WorksheetFunction.range("A1:b2"), Application.WorksheetFunction.range("A3:b4"))
Exit Sub
1:
MsgBox "请输入正确数据", , "出错啦
End Sub

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-8 01:00 , Processed in 0.088182 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表