找回密码
 立即注册
搜索
查看: 716|回复: 7

【求助】帮忙用Visual Basic 2003编译个程序

[复制链接]

34

主题

757

回帖

1051

积分

金牌会员

first

积分
1051
发表于 2005-12-9 06:49:28 | 显示全部楼层 |阅读模式
今天刚装上Visual Studio 2005,发现编译的程序不能在.Net Framework 1.1 下运行。 VS2003 刚删了,哪位老大帮我把下面的程序编译一下。先谢了。


Imports System.IO

Module ChangeNames

    Sub Main()

        Dim strDirToChange As String, intPrefix As Integer, strEnd As String

        Console.Write("Directories to Change: ")
        strDirToChange = Console.ReadLine

        Console.Write("# of Prefix to Change: ")
        intPrefix = Val(Console.ReadLine)

        If Not Directory.Exists(strDirToChange) Then
            Console.Write("Please check the directory path.")
            strEnd = Console.ReadLine
            Exit Sub
        End If

        If intPrefix < 1 Then
            Console.Write("Please check Prefix you want to change.")
            strEnd = Console.ReadLine
            Exit Sub
        End If

        Dim strSubDir1, strSubDir2, strNewName, strPrefix, strMain As String
        Dim intIndex As Integer

        On Error Resume Next
        For Each strSubDir1 In Directory.GetDirectories(strDirToChange)
            For Each strSubDir2 In Directory.GetDirectories(strSubDir1)
                intIndex = strSubDir2.LastIndexOf("\")
                strMain = Mid(strSubDir2, intIndex + 2 + intPrefix + 1, strSubDir2.Length)
                strPrefix = Mid(strSubDir2, intIndex + 2, intPrefix)
                strNewName = strMain & "_" & strPrefix
                My.Computer.FileSystem.RenameDirectory(strSubDir2, strNewName)
            Next
        Next

        Console.Write("All the directories have been successfully renamed.")
        strEnd = Console.ReadLine

    End Sub

End Module

23

主题

397

回帖

546

积分

高级会员

积分
546
发表于 2005-12-9 09:35:16 | 显示全部楼层
用CSC编译啊
本人为:海浩二炮军团司令
回复

使用道具 举报

2

主题

202

回帖

301

积分

中级会员

积分
301
发表于 2005-12-9 13:01:09 | 显示全部楼层
My是vb2005新增的命名空间.不能在 vs2003下编译通过.
回复

使用道具 举报

34

主题

757

回帖

1051

积分

金牌会员

first

积分
1051
 楼主| 发表于 2005-12-9 13:34:52 | 显示全部楼层
下面这个可以了吧。


Imports System.IO

public module ChangeNames

sub Main
               
    Dim strDirToChange As String, intPrefix As Integer, strEnd As String

    Console.Write("Directories to Change: ")
    strDirToChange = Console.ReadLine

    Console.Write("# of Prefix to Change: ")
    intPrefix = cInt(Console.ReadLine)

    If Not Directory.Exists(strDirToChange) Then
        Console.Write("Please check the directory path.")
        strEnd = Console.ReadLine
        Exit Sub
    End If

    If intPrefix < 1 Then
        Console.Write("Please check Prefix you want to change.")
        strEnd = Console.ReadLine
        Exit Sub
    End If

    Dim strSubDir1, strSubDir2, strNewName, strPrefix, strMain As String
    Dim intIndex As Integer

    On Error Resume Next
    For Each strSubDir1 In Directory.GetDirectories(strDirToChange)
        For Each strSubDir2 In Directory.GetDirectories(strSubDir1)
            intIndex = strSubDir2.LastIndexOf("\")
            strMain = Mid(strSubDir2, intIndex + 2 + intPrefix + 1, strSubDir2.Length)
            strPrefix = Mid(strSubDir2, intIndex + 2, intPrefix)
            strNewName = strMain & "_" & strPrefix
            Directory.Move(strSubDir2, strSubDir1 & "\" & strNewName)
        Next
    Next

    Console.Write("All the directories have been successfully renamed.")
    strEnd = Console.ReadLine
               
end sub

end module
回复

使用道具 举报

34

主题

757

回帖

1051

积分

金牌会员

first

积分
1051
 楼主| 发表于 2005-12-9 13:44:11 | 显示全部楼层
谢谢帮忙的老大了,搞定了。有个软件叫Snippet Compiler可以编译 . NET的程序,编译时可以设定 .NET 1.1还是2.0。

服务器上有几百个目录要改名,系统是Windows 2003 SP1,.NET 1.1,不想装  .NET 2.0,怕把服务器搞死了。随手搞了个小程序改名,无奈VS 2005只能编译 .NET 2.0的。研究了半天也没搞明白怎么设置MSBuild,又不想再装VS 2003,有点焦头烂额。最后用Snippet Compiler解决了问题,这是一个不错的东东。
回复

使用道具 举报

1678

主题

5167

回帖

9302

积分

荣誉版主

沉痛悼念小于……

积分
9302
发表于 2005-12-9 14:22:42 | 显示全部楼层
我运行的时候它说名称“Console”未声明。

这是怎么回事?
人似秋鸿来有信,事如春梦了无痕
回复

使用道具 举报

34

主题

757

回帖

1051

积分

金牌会员

first

积分
1051
 楼主| 发表于 2005-12-10 01:55:33 | 显示全部楼层
这些没加上?

imports Microsoft.VisualBasic
imports System
imports System.Collections
Imports System.IO
回复

使用道具 举报

108

主题

949

回帖

1420

积分

金牌会员

积分
1420
发表于 2005-12-10 08:54:12 | 显示全部楼层
我要去看看这个好工具
为了下载而下载
为了沟通而聊天
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|海浩社区

GMT+8, 2025-9-17 05:55 , Processed in 0.098351 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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