程式转换一问
时间:2014-05-29
来源:互联网

[ 本帖最后由 alee001 於 2014-5-10 10:55 PM 编辑 ]
作者: alee001 发布时间: 2014-05-29
想请问如果将含VBA Excel File转换为其他程式执行(例如VB),会唔会好复杂?

作者: 烟民比食屎9更贱 发布时间: 2014-05-29
想请问如果将含VBA Excel File转换为其他程式执行(例如VB),会唔会好复杂?

我 N 年前整过

d code 好似咁样的,你见同 excel vba 差唔多咁。
Dim objApp As Excel.Application
Dim objBook As Excel._Workbook
Dim objBooks As Excel.Workbooks
Dim objSheets As Excel.Sheets
Dim objSheet As Excel._Worksheet
Dim objRange As Excel.Range
' Instantiate Excel and start a new workbook.
objApp = New Excel.Application()
objBooks = objApp.Workbooks
objBook = objBooks.Add
objSheets = objBook.Worksheets
objSheet = objSheets.Item(1)
objRange = objSheet.Range("A1")
'Set the range value.
objRange.Value(Excel.XlRangeValueDataType.xlRangeValueDefault) = "Hello, World!"
'Return control of Excel to the user.
objApp.Visible = True
objApp.UserControl = True
End Sub
作者: yuki~~ 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
咁旧版VB系有个内置转换VBA功能?
作者: 烟民比食屎9更贱 发布时间: 2014-05-29
转 VB/ VB.NET 应好多野都用得返,你可以 google 一下 vb office automation excel
我 N 年前整过

d code 好似咁样的,你见同 excel vba 差唔多咁。
Private Sub Button1_Click(ByVal sender ...

作者: 烟民比食屎9更贱 发布时间: 2014-05-29

作者: alee001 发布时间: 2014-05-29
多谢各位意见,本来谂著将VBA转做VB再修改成.NET版,但睇黎无望...

作者: 烟民比食屎9更贱 发布时间: 2014-05-29
想请问如果将含VBA Excel File转换为其他程式执行(例如VB),会唔会好复杂?

作者: a8d7e8 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
每一种特别用法 post 一款就够, 重覆的不用
成几百行又唔系几十行CODE,当中有又过百条Excel自定公式,成几十MB File,运行觉得好heavy所以先考虑转换...
作者: a8d7e8 发布时间: 2014-05-29
Date input
Date setting
Date test
Date chart
Date analysis
完成整个流程最少须时2hr视乎Data多少。一直想将file写成Add-Ins或执行程式,只系唔知点入手?

作者: alee001 发布时间: 2014-05-29
其实File都系用VBA几种基本型态写Code(i.e. IF...else; For loop; UserForm)再加上Excel巢状公式组成,全部由以下5个step按钮同几个worksheet控制:
Date input
Date setting
Date test
Date chart
Date analysi ...
作者: 烟民比食屎9更贱 发布时间: 2014-05-29
作者: skww 发布时间: 2014-05-29

作者: alee001 发布时间: 2014-05-29
Have you put:
application.screenupdating = false
before you run your data?
turn it on when done. You will see the difference.
作者: stevie1 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
除非你每条row都有好多嘢要搞啦

作者: skww 发布时间: 2014-05-29
作者: stevie1 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
Are you sure the bottleneck is the per statement execution overhead of VBA that cannot be further fine tuned? (That you hope converting it to another Language would speed it up)
There are a lot of formule be structured for statement and result per row on sheet besides VBA step button.
作者: a8d7e8 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
There seems to be a timer function in recent Excel (10 years ago, let say).
Something like setTimeout "funcToInvoke()", for sure the function name is fake here...
Yes, input more data row will creat more formula per row which to cause spend more running time for VBA, I think it may be diffcult to change other lauguage with part of statement formula.
作者: a8d7e8 发布时间: 2014-05-29

作者: alee001 发布时间: 2014-05-29
Without having access to a stereotype of your code or sample data, I can hardly see beyond the black box without inventing the black box myself first.
Probably if you can transform the operation into other equivalent forms, all of us here can contribute more to your problem.
Maybe you can leave out the critical parts, substitute with meaningless but time complexity equivalent operations.........
I used to Excel 2010, I had made optimization of code (eg. copy statement formule after looping to avoid calcuration on VBA running) but it seems a little improve to running time...

作者: a8d7e8 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
Do you have an example?
t1: state A
t2: state A
:
tx-1: state A
tx: state B
:
tn: state B
Is this correct? But how to evaluate the state? Is it a black box? Is it a random function or non-deterministic function.....
That means.....the following:
t1: state At2: state A:tx-1: state Atx: state B:tx+m: state Btx+m+1: state ANY other than B:tn: state ANY
作者: a8d7e8 发布时间: 2014-05-29
[ 本帖最后由 alee001 於 2014-5-15 04:46 PM 编辑 ]
作者: alee001 发布时间: 2014-05-29
Yes, state (state A, state B or state C)change on Excel statement formula cell per row depend on input tick [t] to [t+n], I want to find out state change tick [t+x] (i.e. state [t] state [t-1])
作者: a8d7e8 发布时间: 2014-05-29
before your process starts,
Application.Calculation = xlCalculationManual
after done,
Application.Calculation = xlCalculationAutomatic
will improve the speed.
unless, your task need immediately calculation...
作者: stevie1 发布时间: 2014-05-29
作者: stevie1 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
Must be xlCalculationAutomatic because of formula cell and VBA are interactive.
I doubt, you need to turn the auto-calculation always on, while putting values into the worksheets.
It could either, be better designed, or even, move most (if not all) of the formula inside worksheet to the vba code instead.
There is another trick.
Leave the Workbook in Manual Calculation mode, and just have those sheets calculate whenever they change.e.g. Sheets("Summary1").Calculate
作者: stevie1 发布时间: 2014-05-29
有啲dynamic way可以简约就简约,放入function去计,去简化一啲validation, 再output array 都可以speed up好多,
有啲情况系可以你spreadsheet度计完一部分,将佢copy paste变做value,再放formula计其他部分,咁样去track 嗰个calculation process都可以好快,但系就要花好多啲时间写
作者: honyin 发布时间: 2014-05-29
35楼#:你既提议我已经用紧,将全部计完公式转做value会系可以减少运算时间,但步骤又会多啲,所以最后冇乜点快,我只系部分咁做。
作者: alee001 发布时间: 2014-05-29
If your data range contains high low high low high low, the states maybe changed from A to B to A to B.....etc
Sorry can't help.
I had wrote program find out changing tick with scan from low to high value by looping, I want to try re-write process by Bisection if which spend less time for running by looping on VBA, but I meet p ...
作者: a8d7e8 发布时间: 2014-05-29
[ 本帖最后由 alee001 於 2014-5-16 02:34 PM 编辑 ]
作者: alee001 发布时间: 2014-05-29
t[i+0]....................t[i+0+n] t[i+a]..............t[i+a+n] ...... t[i+z].............t[i+z+n]
Assume you divide the data into m groups each of which is n length and each group can only have a single changing point, then it sufficiently satisfy the requirement of bi-section method that a single "root" or no root is within two points inclusively.
There are too many tutorial about bi-section method ........ so I dont' repeat it here.
I had excluded in case of multi-change on a data betw low and high according to trending, so generally all data only one way changing with two state same as your example 27#. Have you any idea about B ...
作者: a8d7e8 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
Assume your function f(x) is either -1 (low) or 1 (high) and f(a) < f(b).
Target: Find r such that f(a) <= f(r) < f(b) or f(a) < f(r) <= f(b).
while b-a > 1, loop
m = (a+b)/2
If f(a) < f(m), b = m
Else If f(m) < f(b), a = m
Else no root
end loop
Take a if you want the -1 side or b if you want the 1 side.
Thks for your point. I had tried to find process of bisection basiclly from website, I can divide n group and check low to high each group to find out which one state will be changed then scan tick de ...
作者: a8d7e8 发布时间: 2014-05-29
或者research吓advance sorting algorithm
作者: honyin 发布时间: 2014-05-29
Low tick = 10.5
High tick = 11
delta = 0.02
mid-value = (10.5+11)/2 = 10.75
change tick = 10.74 next tick 10.76
Therefore
group 1 = 10.5~10.74
group 2 = 10.76~11
How to make m value ceiling to tick value?
作者: alee001 发布时间: 2014-05-29
My problem is m value is not term of tick value, as follow:
Low tick = 10.5
High tick = 11
delta = 0.02
mid-value = (10.5+11)/2 = 10.75
change tick = 10.74 next tick 10.76
Therefore
group 1 = ...
作者: a8d7e8 发布时间: 2014-05-29
作者: alee001 发布时间: 2014-05-29
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28