我需要转换vba代码到c# [英] i need a convert vba code to c#

查看:226
本文介绍了我需要转换vba代码到c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将vba代码转换为c#

i need convert vba code to c#

Private Sub CMDdownload_Click()
   Dim dbs As Database
Set dbs = CurrentDb
 
    Dim dwEnrollNumber As Long
    Dim dwVerifyMode As Long
    Dim dwInOutMode As Long
    Dim timeStr As String
    Dim rstData As Recordset
    
Set rstData = dbs.OpenRecordset("select * from [CHECKINOUT]")

If CZKEM1.ReadGeneralLogData(CInt(txtMachNum.Value)) Then
ProgressBar0.Max = HCount
ProgressBar0.Value = 0
While CZKEM1.GetGeneralLogDataStr(CInt(txtMachNum.Value), dwEnrollNumber, dwVerifyMode, dwInOutMode, timeStr)
               
               If dwInOutMode = 3 Then dwInOutMode = 0

               SF = "(timeStr = #" & timeStr & "#" & ") And (dwEnrollNumber = " & dwEnrollNumber & ") And (dwInOutMode = " & dwInOutMode & ")"

                rstData.FindFirst SF
                    If rstData.NoMatch Then
                        rstData.AddNew
                        rstData.Fields(0).Value = dwEnrollNumber
                        rstData.Fields(1).Value = timeStr
                        rstData.Fields(2).Value = dwInOutMode
                        rstData.Update
                        Subdawam3.Form.Requery
                    End If
DoCmd.Hourglass (-1)
ProgressBar0.Value = ProgressBar0.Value + 1
Wend
DoCmd.Hourglass (0)

End If
End Sub

推荐答案

由于以下几个原因,无法将上述代码从VBA直接转换为C#,即:

1)它是MS Access的VBA代码(设置dbs = CurrentDb

2) OpenRecordset [ ^ ]是旧的 DAO [ ^ ] 方法; C#使用 ADO.NET [ ^ ]。

3) ReadGeneralLogData GetGeneralLogDataStr 是自定义函数,

4)。 ..



请帮忙,用.net对象,方法和函数自己编写。
It's not possible to convert above code in direct way from VBA to C# because of several reasons, i.e.:
1) it's a VBA code for MS Access (Set dbs = CurrentDb)
2) OpenRecordset[^] is old DAO[^] method; C# uses ADO.NET[^].
3) ReadGeneralLogData and GetGeneralLogDataStr are custom functions,
4) ...

Please do a favour for you and write it yourself using .net objects, methods and functions.


我会建议你逐行浏览并尝试在C#中找到相应的代码。



您将从两个方面受益。



  • 您将理解代码。
  • 您将学习一些C#语法及其用法。
I would suggest you to go through line by line and try to find the equivalent code in C#.

You will be benefited in two ways.

  • You will understand the code.
  • You will learn some C# syntax and their usage.


好的,请自己试试。可能这里的任何人都不会为你转换它。如果你理解那里的逻辑那么这样做不会那么困难。

如果没有那么请在 Google [ ^ ]并选择一个符合您要求的人。
Ok,so try that yourself.Possibly anyone here are not going to convert it for you.If you understand the logic behind there then it would not be so much difficult to do that.
If not then let a search in Google[^] and pick one which fulfill your requirement.


这篇关于我需要转换vba代码到c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆