在网上看到很多asp.net的类,都是用c#写的.如:
public string Extension
{
  get
  {
 if(extension!="") return extension;
 return "txt";
  }
  set
  {
 extension=value;
  }
}public string PathToName(string path)
{
 int pos=path.LastIndexOf("\\");
 return path.Substring(pos+1);
}public string Upload()
{
if(PostedFile!=null)
{
try{
 string fileName=PathToName(PostedFile.FileName);
 if(!fileName.EndsWith(Extension)) return "You must select "+Extension+" file!";
 if(PostedFile.ContentLength>FileLength) return "File too big!";
 PostedFile.SaveAs(SavePath+fileName);
 return "Upload File Successfully!";
}
catch(System.Exception exc)
{return exc.Message;}
}
return "Please select a file to upload!";
}
}
}请问以上的类文件可以用vb来写吗?功能是不是一样的呢?谢谢.

解决方案 »

  1.   

    你用vb.net来编写,生成dll,
    在.net语言中都能调用.
      

  2.   

    ------VB版
    Public Property Extension() As String
       Get
          If extension <> "" Then
             Return extension
          End If
          Return "txt"
       End Get
       Set
          extension = value
       End Set
    End Property
    Public Function PathToName(path As String) As String
       Dim pos As Integer = path.LastIndexOf("\")
       Return path.Substring((pos + 1))
    End Function 'PathToName
    Public Function Upload() As String
       If Not (PostedFile Is Nothing) Then
          Try
             Dim fileName As String = PathToName(PostedFile.FileName)
             If Not fileName.EndsWith(Extension) Then
                Return "You must select " + Extension + " file!"
             End If
             If PostedFile.ContentLength > FileLength Then
                Return "File too big!"
             End If
             PostedFile.SaveAs((SavePath + fileName))
             Return "Upload File Successfully!"
          Catch exc As System.Exception
             Return exc.Message
          End Try
       End If
       Return "Please select a file to upload!"
    End Function 'Upload
    '
    'ToDo: Error processing original source shown below
    '
    '
    '-^--- expression expected
    '
    'ToDo: Error processing original source shown below
    '
    '
    '-^--- expression expected