vbs到vb.net [英] vbs to vb.net

查看:109
本文介绍了vbs到vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




几个问题:


1.我需要根据文本文件中的某些信息重命名PDF。

有人给了我一些vbs代码(见下文),我想转换成

VB.net。我想要GUI和vb.net应用程序来查看文件的文件夹来显示 - 我想我有很好的''filewatcher''代码。但是,我b $ b尝试使用vbs代码逻辑来创建一个新的vb.net可执行文件而没有

成功。


将代码转换为在vb.net中运行的最佳方法是什么?在vb.net中有更好的方法吗?


2.对于想要偶尔进行文件操作的人来说,是vb.net

使用正确的编程语言?有人会推荐C,Perl,

VB6或者我甚至没想到的东西?我愿意学习,参加
课程,自学等。


感谢您的帮助或想法!


************

子ReadFiles

''启动过程所需的变量


Dim fso,f1,ts,s

Dim sIndex,sIndex2,sIndex3,sTemp

Dim sIndexArray(1000)

Dim sIndexArray2 (1000)

Dim I,N


Const ForReading = 1

I = 0

设置fso = CreateObject(" Scripting.FileSystemObject")


''读取文件内容。


设置ts = fso。 OpenTextFile(" C:\Output \NewNames.txt",ForReading,

False)


''循环通过索引文本记录。


Do while ts.AtEndOfStream< True


''初始化sIndex变量


sIndex =" ;"


sIndex2 =""


sIndex3 =""


sTemp =""


''读取索引文本文件中的记录。


s = ts.ReadLine
如果Mid(s,5,1)<" C"然后


sIndex = Mid(s,2,8)''新指数。

sIndex2 = Mid(s,27,8)''旧版PDF姓名。

sIndex3 = Mid(s,27,12)''旧PDF名称带pdf

扩展名。

sTemp =替换(s ,sIndex2,sIndex)''替换旧PDF

带有索引信息的名称。


I = I + 1''增量

计数器。


sIndexArray(I)= Mid(sTemp,27,12)''添加新PDF

名称和pdf文件到数组移动和重命名。


sIndexArray2(I)= sIndex3''将旧的PDF名称添加到

阵列进行移动和重命名

Else

N = N + 1

结束如果

循环


''垃圾收集

ts.Close


Do I = 1


''将旧的PDF文件移动并重命名为新建文件夹。将旧的PDF

文件重命名为新的PDF文件。


fso.MoveFile" C:\Output\" &安培; sIndexArray2(I)& ",",

" C:\ perfect {\\" &安培; sIndexArray(I)& "


I = I - 1


循环


''删除输出文件。


fso.DeleteFile(" C:\ Output \NewNames.txt")

End Sub


ReadFiles

解决方案

抱歉兄弟... VB 2005不支持翻译VBS文件或VBA文件< br $>
或VB Projects以外的任何东西。


对吗?


我觉得你更好了从头开始重写


-Aaron

DorkyGrin写道:





几个问题:


1.我需要根据文本文件中的某些信息重命名PDF。

有人给了我一些vbs代码(见下文),我想转换成

VB.net。我想要GUI和vb.net应用程序来查看文件的文件夹来显示 - 我想我有很好的''filewatcher''代码。但是,我b $ b尝试使用vbs代码逻辑来创建一个新的vb.net可执行文件而没有

成功。


将代码转换为在vb.net中运行的最佳方法是什么?在vb.net中有更好的方法吗?


2.对于想要偶尔进行文件操作的人来说,是vb.net

使用正确的编程语言?有人会推荐C,Perl,

VB6或者我甚至没想到的东西?我愿意学习,参加
课程,自学等。


感谢您的帮助或想法!


************


子ReadFiles

''启动过程所需的变量


Dim fso,f1,ts,s

Dim sIndex,sIndex2,sIndex3,sTemp

Dim sIndexArray(1000)

Dim sIndexArray2(1000)

Dim I,N


Const ForReading = 1

I = 0

设置fso = CreateObject(" Scripting.FileSystemObject")


''读取文件内容。


Set ts = fso.OpenTextFile(" C:\ Onutut \NewNames.txt",ForReading,

False)


''循环直通索引文本记录。


Do ts.AtEndOfStream< True


''初始化sIndex变量


sIndex =""


sIndex2 =" ;"


sIndex3 =""


sTemp =""


''读取索引文本文件中的记录。


s = ts.ReadLine


如果Mid(s,5,1)<" ; C"然后


sIndex = Mid(s,2,8)''新指数。


sIndex2 = Mid(s,27,8) ''旧PDF名称。


sIndex3 = Mid(s,27,12)''旧PDF名称,带pdf

扩展名。


sTemp =替换(s,sIndex2,sIndex)''替换旧PDF

带有索引信息的名称。


I = I + 1''递增

柜台。


sIndexArray(I)= Mid(sTemp,27,12)''添加新PDF

名称和pdf文件到数组用于移动和重命名。


sIndexArray2(I)= sIndex3''将旧的PDF名称添加到

数组中移动和重命名

否则

N = N + 1

结束如果

循环

''垃圾收集


ts.Close


Do I = 1


''将旧PDF文件移动并重命名为新文件夹。将旧的PDF

文件重命名为新的PDF文件。


fso.MoveFile" C:\Output\" &安培; sIndexArray2(I)& ",",

" C:\ perfect {\\" &安培; sIndexArray(I)& "


I = I - 1


循环


''删除输出文件。


fso.DeleteFile(" C:\ Output \NewNames.txt")

End Sub


ReadFiles


如果这是真的,我认为这很疯狂。好像一个人应该能够将这个VBS内容放到vb.net中并进行一些小改动,编译

它并拥有一个不错的小应用程序。 />

有关重写VB.net代码的任何想法吗?也许流道阅读器

的东西是一个很好的起点。


任何人?

aa ********* @ gmail.com 写道:


对不起兄弟.. VB 2005不支持翻译VBS文件或VBA文件

或VB Projects以外的任何东西。


对吗?


我认为你最好从头开始重写它


-Aaron


DorkyGrin写道:





几个问题:


1.我需要根据文本文件中的某些信息重命名PDF。

有人给了我一些vbs代码(见下文)我想转换成

VB 。净。我想要GUI和vb.net应用程序来查看文件的文件夹来显示 - 我想我有很好的''filewatcher''代码。但是,我b $ b尝试使用vbs代码逻辑来创建一个新的vb.net可执行文件而没有

成功。


将代码转换为在vb.net中运行的最佳方法是什么?在vb.net中有更好的方法吗?


2.对于想要偶尔进行文件操作的人来说,是vb.net

使用正确的编程语言?有人会推荐C,Perl,

VB6或者我甚至没想到的东西?我愿意学习,参加
课程,自学等。


感谢您的帮助或想法!


************

子ReadFiles

''启动过程所需的变量


Dim fso,f1,ts,s

Dim sIndex,sIndex2,sIndex3,sTemp

Dim sIndexArray(1000)

Dim sIndexArray2 (1000)

Dim I,N


Const ForReading = 1

I = 0

设置fso = CreateObject(" Scripting.FileSystemObject")


''读取文件内容。


设置ts = fso。 OpenTextFile(" C:\Output \NewNames.txt",ForReading,

False)


''循环通过索引文本记录。


Do while ts.AtEndOfStream< True


''初始化sIndex变量


sIndex =" ;"


sIndex2 =""


sIndex3 =""


sTemp =""

>
''读取索引文本文件中的记录。


s = ts.ReadLine

如果Mid(s,5,1)<" ; C"然后


sIndex = Mid(s,2,8)''新指数。

sIndex2 = Mid(s,27,8)''旧版PDF姓名。

sIndex3 = Mid(s,27,12)''旧PDF名称带pdf

扩展名。

sTemp =替换(s ,sIndex2,sIndex)''替换旧PDF

带有索引信息的名称。


I = I + 1''增量

计数器。


sIndexArray(I)= Mid(sTemp,27,12)''添加新PDF

名称和pdf文件到数组移动和重命名。


sIndexArray2(I)= sIndex3''将旧的PDF名称添加到

阵列进行移动和重命名

Else

N = N + 1

结束如果

循环


''垃圾收集

ts.Close


做什么ile I = 1


''将旧的PDF文件移动并重命名为新文件夹。将旧的PDF

文件重命名为新的PDF文件。


fso.MoveFile" C:\Output\" &安培; sIndexArray2(I)& ",",

" C:\ perfect {\\" &安培; sIndexArray(I)& "


I = I - 1


循环


''删除输出文件。


fso.DeleteFile(" C:\ Output \NewNames.txt")

End Sub


ReadFiles


它''显然是真的。


微软没有没有意识到世界上90%的VB6代码 - 它是b / b
从未生活在真正的VB6中;它住在VBA / VBS。


显然他们没有给你一个废话。


我只是认为一堆迟钝三年级学生可以设计一个更有效的代码翻译器;或者就此而言;语言和IDE。


VB.net在公开市场上完全失败。

你应该放弃并将所有东西都转移到PHP。


-Aaron


DorkyGrin写道:


如果这是真的,我认为这太疯狂了。好像一个人应该能够将这个VBS内容放到vb.net中并进行一些小改动,编译

它并拥有一个不错的小应用程序。 />

有关重写VB.net代码的任何想法吗?也许流道阅读器

的东西是一个很好的起点。


任何人?

aa ********* @ gmail.com 写道:


对不起兄弟.. VB 2005不支持翻译VBS文件或VBA文件

或VB Projects以外的任何东西。


对吗?


我认为你最好从头开始重写它


-Aaron

DorkyGrin写道:




>

几个问题:

>

1.我需要根据文本文件中的某些信息重命名PDF。

有人给了我一些vbs代码(见下文)我想转换成

VB.net。我想要GUI和vb.net应用程序来查看文件的文件夹来显示 - 我想我有很好的''filewatcher''代码。但是,我b $ b试图使用vbs代码逻辑来创建一个新的vb.net可执行文件,而没有

成功。

>

将代码转换为在vb.net中运行的最佳方法是什么?在vb.net中有更好的方法吗?

>

2.对于想要偶尔进行文件操作的人,是vb.net

使用正确的编程语言?有人会推荐C,Perl,

VB6或者我甚至没想到的东西?我愿意学习,参加
课程,自学等。

>

感谢您的帮助或想法!

>

************

>

>

子ReadFiles

''启动过程所需的变量

>

Dim fso,f1,ts,s

Dim sIndex,sIndex2,sIndex3,sTemp

Dim sIndexArray(1000)

Dim sIndexArray2(1000)

Dim我,N

>

Const ForReading = 1

I = 0

设置fso = CreateObject(" ; Scripting.FileSystemObject")

>

''阅读文件内容。

>

设置ts = fso.OpenTextFile(" C:\Output \NewNames.txt",ForReading,

False)

>

''循环通过索引文本记录。

>

Do ts.AtEndOfStream< True

& gt;

''初始化sIndex变量

>

sIndex =""

>

sIndex2 =""

>

sIndex3 =""

>

sTemp =""

>

''读取索引文本文件中的记录。

>

s = ts.ReadLine

>

>

如果Mid(s,5,1)<" ; C"然后

>

sIndex = Mid(s,2,8)''新指数。

>

>

sIndex2 = Mid(s,27,8)''旧PDF名称。

>

>

sIndex3 = Mid(s,27,12)''旧PDF名称,带pdf

扩展名。

>

>

sTemp =替换(s,sIndex2,sIndex)''替换旧PDF

带索引信息的名称。

>

I = I + 1''递增

计数器。

>

sIndexArray(I)= Mid( sTemp,27,12)''添加新的PDF

名称和pdf文件到阵列进行移动和重命名。

>

sIndexArray2( I)= sIndex3''将旧的PDF名称添加到

阵列进行移动和重命名

否则

N = N + 1

结束如果

循环

>

''垃圾收集

>

t.Close

>

Do I = 1

>

''移动并重命名旧PDF文件到新文件夹。将旧的PDF

文件重命名为新的PDF文件。

>

fso.MoveFile" C:\Output\" &安培; sIndexArray2(I)& ",",

" C:\ perfect {\\" &安培; sIndexArray(I)& "

>

我= I - 1

>

循环

>

''删除输出文件。

>

fso.DeleteFile(" C:\Output\NewNames .txt")

>

结束子

>

ReadFiles


Hi,

Couple of questions:

1. I need to rename a PDF based on some information inside a text file.
Someone gave me some vbs code (see below) that I''d like to convert into
VB.net. I want GUI and the vb.net app to watch a folder for a file to
show up - I think I have good ''filewatcher'' code for that. However, I
tried to use the vbs code logic to make a new vb.net executable with no
success.

What is the best way to convert the code to run in vb.net? Is there a
better way to do this in vb.net?

2. For someone that wants to do occasional file manipulation, is vb.net
the right programming language to use? Would anyone recommend C, Perl,
VB6 or something I''m not even thinking of? I''m willing to learn, take
classes, self study etc.

Thanks for any help or ideas!

************
Sub ReadFiles
'' Variables needed to initiate process

Dim fso, f1, ts, s
Dim sIndex, sIndex2, sIndex3, sTemp
Dim sIndexArray(1000)
Dim sIndexArray2(1000)
Dim I, N

Const ForReading = 1
I = 0
Set fso = CreateObject("Scripting.FileSystemObject")

'' Read the contents of the file.

Set ts = fso.OpenTextFile("C:\Output\NewNames.txt", ForReading,
False)

'' Loop thru Index text records.

Do While ts.AtEndOfStream <True

'' Initialize sIndex variables

sIndex = ""

sIndex2 = ""

sIndex3 = ""

sTemp = ""

'' Read Records in Index text file.

s = ts.ReadLine
If Mid(s,5,1) <"C" Then

sIndex = Mid(s,2,8) '' New Index.
sIndex2 = Mid(s,27,8) '' Old PDF Name.
sIndex3 = Mid(s,27,12) '' Old PDF Name with pdf
extension.
sTemp = Replace(s,sIndex2, sIndex) ''Replaces Old PDF
Name with Index information.

I = I + 1 '' Increment
counter.

sIndexArray(I) = Mid(sTemp,27,12) '' Add new PDF
Name and pdf file to array for moving and renaming.

sIndexArray2(I) = sIndex3 '' Add old PDF Name to
array for moving and renaming
Else
N = N + 1
End If
Loop

'' Garbage collection

ts.Close

Do While I =1

'' Move and rename old PDF file to new folder. Rename old PDF
file to new PDF file.

fso.MoveFile "C:\Output\" & sIndexArray2(I) & "",
"C:\completed\" & sIndexArray(I) & " "

I = I - 1

Loop

'' Delete output file.

fso.DeleteFile("C:\Output\NewNames.txt")

End Sub

ReadFiles

解决方案

sorry bro.. VB 2005 doesn''t support translating VBS files or VBA files
or anything other than VB Projects.

RIGHT?

I think that you''re hosed you better rewrite it from scratch

-Aaron
DorkyGrin wrote:

Hi,

Couple of questions:

1. I need to rename a PDF based on some information inside a text file.
Someone gave me some vbs code (see below) that I''d like to convert into
VB.net. I want GUI and the vb.net app to watch a folder for a file to
show up - I think I have good ''filewatcher'' code for that. However, I
tried to use the vbs code logic to make a new vb.net executable with no
success.

What is the best way to convert the code to run in vb.net? Is there a
better way to do this in vb.net?

2. For someone that wants to do occasional file manipulation, is vb.net
the right programming language to use? Would anyone recommend C, Perl,
VB6 or something I''m not even thinking of? I''m willing to learn, take
classes, self study etc.

Thanks for any help or ideas!

************
Sub ReadFiles
'' Variables needed to initiate process

Dim fso, f1, ts, s
Dim sIndex, sIndex2, sIndex3, sTemp
Dim sIndexArray(1000)
Dim sIndexArray2(1000)
Dim I, N

Const ForReading = 1
I = 0
Set fso = CreateObject("Scripting.FileSystemObject")

'' Read the contents of the file.

Set ts = fso.OpenTextFile("C:\Output\NewNames.txt", ForReading,
False)

'' Loop thru Index text records.

Do While ts.AtEndOfStream <True

'' Initialize sIndex variables

sIndex = ""

sIndex2 = ""

sIndex3 = ""

sTemp = ""

'' Read Records in Index text file.

s = ts.ReadLine
If Mid(s,5,1) <"C" Then

sIndex = Mid(s,2,8) '' New Index.
sIndex2 = Mid(s,27,8) '' Old PDF Name.
sIndex3 = Mid(s,27,12) '' Old PDF Name with pdf
extension.
sTemp = Replace(s,sIndex2, sIndex) ''Replaces Old PDF
Name with Index information.

I = I + 1 '' Increment
counter.

sIndexArray(I) = Mid(sTemp,27,12) '' Add new PDF
Name and pdf file to array for moving and renaming.

sIndexArray2(I) = sIndex3 '' Add old PDF Name to
array for moving and renaming
Else
N = N + 1
End If
Loop

'' Garbage collection

ts.Close

Do While I =1

'' Move and rename old PDF file to new folder. Rename old PDF
file to new PDF file.

fso.MoveFile "C:\Output\" & sIndexArray2(I) & "",
"C:\completed\" & sIndexArray(I) & " "

I = I - 1

Loop

'' Delete output file.

fso.DeleteFile("C:\Output\NewNames.txt")

End Sub

ReadFiles


If that''s true, I think it is crazy. Seems like a guy ought to be able
to drop that VBS stuff into vb.net and with some minor changes, compile
it and have a nice little app.

Any ideas on rewriting the code for VB.net? Perhaps the streamreader
stuff is a good place to start.

anyone?

aa*********@gmail.com wrote:

sorry bro.. VB 2005 doesn''t support translating VBS files or VBA files
or anything other than VB Projects.

RIGHT?

I think that you''re hosed you better rewrite it from scratch

-Aaron
DorkyGrin wrote:

Hi,

Couple of questions:

1. I need to rename a PDF based on some information inside a text file.
Someone gave me some vbs code (see below) that I''d like to convert into
VB.net. I want GUI and the vb.net app to watch a folder for a file to
show up - I think I have good ''filewatcher'' code for that. However, I
tried to use the vbs code logic to make a new vb.net executable with no
success.

What is the best way to convert the code to run in vb.net? Is there a
better way to do this in vb.net?

2. For someone that wants to do occasional file manipulation, is vb.net
the right programming language to use? Would anyone recommend C, Perl,
VB6 or something I''m not even thinking of? I''m willing to learn, take
classes, self study etc.

Thanks for any help or ideas!

************
Sub ReadFiles
'' Variables needed to initiate process

Dim fso, f1, ts, s
Dim sIndex, sIndex2, sIndex3, sTemp
Dim sIndexArray(1000)
Dim sIndexArray2(1000)
Dim I, N

Const ForReading = 1
I = 0
Set fso = CreateObject("Scripting.FileSystemObject")

'' Read the contents of the file.

Set ts = fso.OpenTextFile("C:\Output\NewNames.txt", ForReading,
False)

'' Loop thru Index text records.

Do While ts.AtEndOfStream <True

'' Initialize sIndex variables

sIndex = ""

sIndex2 = ""

sIndex3 = ""

sTemp = ""

'' Read Records in Index text file.

s = ts.ReadLine
If Mid(s,5,1) <"C" Then

sIndex = Mid(s,2,8) '' New Index.
sIndex2 = Mid(s,27,8) '' Old PDF Name.
sIndex3 = Mid(s,27,12) '' Old PDF Name with pdf
extension.
sTemp = Replace(s,sIndex2, sIndex) ''Replaces Old PDF
Name with Index information.

I = I + 1 '' Increment
counter.

sIndexArray(I) = Mid(sTemp,27,12) '' Add new PDF
Name and pdf file to array for moving and renaming.

sIndexArray2(I) = sIndex3 '' Add old PDF Name to
array for moving and renaming
Else
N = N + 1
End If
Loop

'' Garbage collection

ts.Close

Do While I =1

'' Move and rename old PDF file to new folder. Rename old PDF
file to new PDF file.

fso.MoveFile "C:\Output\" & sIndexArray2(I) & "",
"C:\completed\" & sIndexArray(I) & " "

I = I - 1

Loop

'' Delete output file.

fso.DeleteFile("C:\Output\NewNames.txt")

End Sub

ReadFiles


its'' obviously true.

Microsoft doesn''t realize that 90% of the VB6 code in the world-- it
never lived in true VB6; it lives in VBA / VBS.

and apparently they don''t give a crap.

I just think that a bunch of retarded 3rd graders could have designed a
more effective code translator; or for that matter; language and IDE.

VB.net is a complete failure in the open market.
you should give up and move everything to PHP.

-Aaron

DorkyGrin wrote:

If that''s true, I think it is crazy. Seems like a guy ought to be able
to drop that VBS stuff into vb.net and with some minor changes, compile
it and have a nice little app.

Any ideas on rewriting the code for VB.net? Perhaps the streamreader
stuff is a good place to start.

anyone?

aa*********@gmail.com wrote:

sorry bro.. VB 2005 doesn''t support translating VBS files or VBA files
or anything other than VB Projects.

RIGHT?

I think that you''re hosed you better rewrite it from scratch

-Aaron
DorkyGrin wrote:

Hi,
>
Couple of questions:
>
1. I need to rename a PDF based on some information inside a text file.
Someone gave me some vbs code (see below) that I''d like to convert into
VB.net. I want GUI and the vb.net app to watch a folder for a file to
show up - I think I have good ''filewatcher'' code for that. However, I
tried to use the vbs code logic to make a new vb.net executable with no
success.
>
What is the best way to convert the code to run in vb.net? Is there a
better way to do this in vb.net?
>
2. For someone that wants to do occasional file manipulation, is vb.net
the right programming language to use? Would anyone recommend C, Perl,
VB6 or something I''m not even thinking of? I''m willing to learn, take
classes, self study etc.
>
Thanks for any help or ideas!
>
************
>
>
Sub ReadFiles
'' Variables needed to initiate process
>
Dim fso, f1, ts, s
Dim sIndex, sIndex2, sIndex3, sTemp
Dim sIndexArray(1000)
Dim sIndexArray2(1000)
Dim I, N
>
Const ForReading = 1
I = 0
Set fso = CreateObject("Scripting.FileSystemObject")
>
'' Read the contents of the file.
>
Set ts = fso.OpenTextFile("C:\Output\NewNames.txt", ForReading,
False)
>
'' Loop thru Index text records.
>
Do While ts.AtEndOfStream <True
>
'' Initialize sIndex variables
>
sIndex = ""
>
sIndex2 = ""
>
sIndex3 = ""
>
sTemp = ""
>
'' Read Records in Index text file.
>
s = ts.ReadLine
>
>
If Mid(s,5,1) <"C" Then
>
sIndex = Mid(s,2,8) '' New Index.
>
>
sIndex2 = Mid(s,27,8) '' Old PDF Name.
>
>
sIndex3 = Mid(s,27,12) '' Old PDF Name with pdf
extension.
>
>
sTemp = Replace(s,sIndex2, sIndex) ''Replaces Old PDF
Name with Index information.
>
I = I + 1 '' Increment
counter.
>
sIndexArray(I) = Mid(sTemp,27,12) '' Add new PDF
Name and pdf file to array for moving and renaming.
>
sIndexArray2(I) = sIndex3 '' Add old PDF Name to
array for moving and renaming
Else
N = N + 1
End If
Loop
>
'' Garbage collection
>
ts.Close
>
Do While I =1
>
'' Move and rename old PDF file to new folder. Rename old PDF
file to new PDF file.
>
fso.MoveFile "C:\Output\" & sIndexArray2(I) & "",
"C:\completed\" & sIndexArray(I) & " "
>
I = I - 1
>
Loop
>
'' Delete output file.
>
fso.DeleteFile("C:\Output\NewNames.txt")
>
End Sub
>
ReadFiles


这篇关于vbs到vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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