在VB.net中的main方法的用法,总是提示“在“StartUp”中找不到任何具有合适签名的可访问“Main”方法。”

cclover 2003-10-09 10:24:54
我在写完一个程序后,加上main方法后就无法生成,总是提示“在“StartUp”(我写的一个模块)中找不到任何具有合适签名的可访问“Main”方法。”,请高人赐教!!,在下跪谢!!!
以下是代码:
Imports System.IO.File
Imports System
Imports base
Imports RTFunctions
Imports System.Windows.Forms

Public Class A
Sub Main()
Dim currentDate As String = Date.Today
If currentDate.Length < 9 Then
MessageBox.Show("请在控制面板-区域选项 中,将短日期格式改为 'yyyy-mm-dd'!", Global.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End
End If

Global.ComputerName = SystemInformation.ComputerName()
'读取连接字符串
Dim FilePath As String = Application.StartupPath.ToString + "\LinkStr.txt"
If System.IO.File.Exists(FilePath) = True Then
Dim FS As New System.IO.FileStream(FilePath, IO.FileMode.Open)
Dim SW As New System.IO.StreamReader(FS)
Global.LinkStr = SW.ReadToEnd
FS.Close()

'测试连接字符串
Try
Dim Ds As New DataSet()
Dim objConn As New SqlClient.SqlConnection(Global.LinkStr)
Dim Da As New SqlClient.SqlDataAdapter("select * from 用户组", objConn)
Da.Fill(Ds, "table")
Catch err As SqlClient.SqlException
Dim LoginDB As New frmLoginDB()
LoginDB.Show()
Exit Sub
End Try

Dim Login As New frmLogin()
Login.Show()
Exit Sub
Else
Dim LoginDB As New frmLoginDB()
LoginDB.Show()
End If
End Sub
End Class
...全文
480 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
oo渣渣oo 2003-10-09
  • 打赏
  • 举报
回复
sub main不能写在Class里.应该写在Module里
realwolf 2003-10-09
  • 打赏
  • 举报
回复
定义public shared sub main()
ludonglei 2003-10-09
  • 打赏
  • 举报
回复
yes!
jun_01 2003-10-09
  • 打赏
  • 举报
回复
yes!

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧