如何将vb.net代码转换为C# [英] how to convert vb.net code to c#
本文介绍了如何将vb.net代码转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有vb.net代码.
我想将此代码转换为c#.
代码是-
I have vb.net code.
I wanted to convert this code into c#.
The code is-
Sub SentencesToExcel()
Dim appXL As Excel.Application
Dim wbkXLSource As Excel.Workbook
Dim wbkXLNew As Excel.Workbook
Dim strSearch() As String
Dim var
Dim r As Word.Range
Dim j As Long
Set appXL = CreateObject("Excel.Application")
Set wbkXLSource = appXL.Workbooks.Open(FileName:="c:\ZZZ\Test\test2\WordList.xls")
Set wbkXLNew = appXL.Workbooks.Add
For var = 0 To 2
' build the array of search words from the source Excel file
ReDim Preserve strSearch(var)
strSearch(var) = wbkXLSource.Worksheets("Sheet1").Cells(var + 1, 1).Value
Next
' close the source Excel file as do not need it
wbkXLSource.Close
' destroy its object
Set wbkXLSource = Nothing
j = 1
' for each search words
For var = 0 To UBound(strSearch())
' make a range ovbject of the whole document
Set r = ActiveDocument.Range
With r.Find
' with each Found
Do While .Execute(Findtext:=strSearch(var), Forward:=True) _
= True
' expand to the sentence
r.Expand Unit:=wdSentence
' and put in the next cell in the new Excel file
wbkXLNew.Worksheets("Sheet1").Cells(j, 1).Value = r.Text
j = j + 1
r.Collapse 0
Loop
End With
Next
appXL.Visible = True
'wbkXLNew.SaveAs FileName:="valid_path"
'Set wbkXLNew = Nothing
'appXL.Quit
'Set appXL = Nothing
End Sub
推荐答案
通过下面的链接
http://www.developerfusion.com/tools/convert/csharp-to-vb/ [ ^ ]
go through the below link
http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
嗨 您可以使用此链接
http://converter.telerik.com/ [ ^ ]
希望这会有所帮助:)
谢谢
Vinod
Hi You can use this link
http://converter.telerik.com/[^]
Hope this will help :)
Thanks
Vinod
这篇关于如何将vb.net代码转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文