在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
...全文
486 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!
6 , chunks.zip<br>This will open a file and read it in "Chunks" of a selected file.<END><br>7 , logging.zip<br>This is a bas that will log installation procedures so the file can be removed later.<END><br>8 , savetree.zip<br>This will save the info in a Tree View. "This technique allows a program to save hierarchical information like the data in a TreeView in a way that is easy to understand."<END><br>11 , OLE.zip<br>Demonstrates the use of OLE.<END><br>12 , gradtxt2.zip<br>"A program for drawing horizontal, rectangular or spherical gradient texts."<END><br>13 , sweepgl.zip<br>This example greatly demonstrates how to use OpenGL in Visual Basic.<END><br>15 , drawdemo.zip<br>This is an excellent example of how to make a paint program with a few extras.<END><br>16 , cube.zip<br>This example demonstrates how to rotate a cube in visual basic.<END><br>17 , sprite1.zip<br>This is an Excellent example on how to use sprites in your program.<END><br>18 , charcreate.zip<br>This is an example of how to assign "characters" to differant pictureboxes. This would be a good starting point for VB game developers.<END><br>19 , breakthrough.zip<br>This demonstrates a simple game in Visual Basic. An excellent example.<END><br>26 , openlib.zip<br>These are the type libs that go with OpenGL. This is used to make 3D text.<END><br>27 , basMath.zip<br>This module contains functions for various math equations. <END><br>28 , calc.zip<br>This is a basic calculator written in Visual Basic.<END><br>29 , stopwatch.zip<br>This shows how to count off time in a Stop Watch format.<END><br>31 , taskhide.zip<br>This will hide your application from the taskbar, Alt+Tab, and Alt+Ctrl+Del.<END><br>32 , newbie.zip<br>This is a nicely done help file for programmers that are new to Visual Basic.<END><br>33 , vbfaq.zip<br>This is AOL's PC Dev Visual Basic FAQ. This is an excellent starting point for begginners.<END><br>34 , Bas.zip<br>it is very good modual for activex<END><br>35, paraviasource.zip<br>This is
requires software maintenance through 2008.11.19. (Beta release.) New! Added full support for Web and WPF applications, including ASP/ASP.NET, HTML, XML, JavaScript, VBScript, and XAML. Most VA features like Goto, Find References, Suggestions, and VA Outline work with these projects and file types where applicable. New! Highlight find results (case=5141) 8312, 6665, 6397, 6254, 6028 New! Optional tomato icons in listboxes and tooltips denote content provided by Visual Assist X. (case=20290) New! Added support for makefile projects (e.g. solutions without files) by parsing the physical directory tree of files as they are opened. (case=18918) New! Find References results are grouped by project. (case=19512, case=4087) 8174, 8168, 7463, 5742 New! VA Outline optionally auto-expands nodes as the user navigates in the code editor. (case=19617) New! VA Outline remembers the expanded state of each node when refreshing its contents (not applicable when auto-expand is active). (case=8858) 7989, 7903, 7714, 6664 New! Redundant namespace and class names are omitted from VA Outline nodes to save space. (case=13240) 8083, 7387, 7271 New! Enhanced Syntax Coloring uses better default colors when a dark background is in use. (case=17562, case=9431) 8076, 8029, 6607 New! Singe lines of code containing multiple statements are shown as separate nodes in VA Outline. (case=18580) New! Goto (Alt+G) ignores duplicate filenames opened from other locations, so Alt+G on a method in Main\foo.h goes directly to the implementation in Main\foo.cpp even if Branch\foo.cpp was opened for editing at some point. (case=19423) New! Open File in Solution (OFIS) and Find Symbol in Solution (FSIS) dialogs scroll the highlighted entry to the center vertically to aid in viewing surrounding entries. (case=20182, case=19262) New! OFIS shows the project to which a file belongs. (case=764) 8180, 7899, 3966 New! FSIS persists its "Show only symbols defined in the current solution" state between invocations for the current session. (case=20549) Extracted methods with long parameters lists are generated correctly. (case=5802) 8310, 6078 Fixed global scope resolution operator (::) being changed to a single colon in Extract Method. (case=18573) 8021 Extract Method no longer offers to extract to source file when no source file is present. (case=20181) The context menu is available for symbols even if they are unknown or mistyped. (case=19552) 8170 Suggestion lists utilize the Options | Text Editor | C# | IntelliSense | Committed by pressing the space bar setting correctly. (case=10695) 8213, 7273, 7055 Cloned Find References windows are restored after debugging. (case=9511) 6847 VA Options dialog grays out options that depend on Enhanced Syntax Coloring when that option is disabled. (case=3079) 8184 Shorthand and Acronyms work properly in VB 2008. (case=15202) 8257 Fixed unexpected dismissal of suggestion list in VB when typing a type name after the As keyword (case=20261) 8257 The text caret is placed in the correct location after accepting a .NET Generic from a suggestion list in VB 2008. (case=20259) 8257 When typing a parameter in a C# LINQ predicate function, focus is no longer given to the suggestion list, matching the default VS 2008 behavior. (case=16277) C++ keyword __restrict is recognized. (case=20732) 8307 wmemset and wmemcpy are recognized as valid system functions. (case=18414) 7990 Fixed a case where a managed assembly failed to be properly parsed. (case=20071) VA Outline correctly displays C++ #pragma region/endregion nodes. (case=20612) 8274 Multiline XML comments no longer contain extraneous '/' characters in VA Outline. (case=18539) 8005 Document Method correctly handles array parameters when using the $MethodArgName$ VA Snippet variable. (case=20543) 8285 Fixed problem in which enhanced coloring was not applied to Visual Studio text editor (due to certain color settings). (case=18813) 7993 Fixed GDI resource leak that was exacerbated by the presence of an external clipboard manager utility. (case=20137) Parameter Info tooltips for constructors of child classes render each parameter in bold correctly (fixes issue introduced in 1649). (case=20664) VA Options | Performance | Rebuild Symbol databases causes the db files to be purged at IDE shutdown instead of the next startup (performance enhancement). (case=20799) 8319
* New! Added full support for Web and WPF applications, including ASP/ASP.NET, HTML, XML, JavaScript, VBScript, and XAML. Most VA features like Goto, Find References, Suggestions, and VA Outline work with these projects and file types where applicable. * New! Highlight find results (case=5141) 8312, 6665, 6397, 6254, 6028 * New! Optional tomato icons in listboxes and tooltips denote content provided by Visual Assist X. (case=20290) * New! Added support for makefile projects (e.g. solutions without files) by parsing the physical directory tree of files as they are opened. (case=18918) * New! Find References results are grouped by project. (case=19512, case=4087) 8174, 8168, 7463, 5742 * New! VA Outline optionally auto-expands nodes as the user navigates in the code editor. (case=19617) * New! VA Outline remembers the expanded state of each node when refreshing its contents (not applicable when auto-expand is active). (case=8858) 7989, 7903, 7714, 6664 * New! Redundant namespace and class names are omitted from VA Outline nodes to save space. (case=13240) 8083, 7387, 7271 * New! Enhanced Syntax Coloring uses better default colors when a dark background is in use. (case=17562, case=9431) 8076, 8029, 6607 * New! Singe lines of code containing multiple statements are shown as separate nodes in VA Outline. (case=18580) * New! Goto (Alt+G) ignores duplicate filenames opened from other locations, so Alt+G on a method in Main\foo.h goes directly to the implementation in Main\foo.cpp even if Branch\foo.cpp was opened for editing at some point. (case=19423) * New! Open File in Solution (OFIS) and Find Symbol in Solution (FSIS) dialogs scroll the highlighted entry to the center vertically to aid in viewing surrounding entries. (case=20182, case=19262) * New! OFIS shows the project to which a file belongs. (case=764) 8180, 7899, 3966 * New! FSIS persists its "Show only symbols defined in the current solution" state between invocations for the current session. (case=20549) * Extracted methods with long parameters lists are generated correctly. (case=5802) 8310, 6078 * Fixed global scope resolution operator (::) being changed to a single colon in Extract Method. (case=18573) 8021 * Extract Method no longer offers to extract to source file when no source file is present. (case=20181) * The context menu is available for symbols even if they are unknown or mistyped. (case=19552) 8170 * Suggestion lists utilize the Options | Text Editor | C# | IntelliSense | Committed by pressing the space bar setting correctly. (case=10695) 8213, 7273, 7055 * Cloned Find References windows are restored after debugging. (case=9511) 6847 * VA Options dialog grays out options that depend on Enhanced Syntax Coloring when that option is disabled. (case=3079) 8184 * Shorthand and Acronyms work properly in VB 2008. (case=15202) 8257 * Fixed unexpected dismissal of suggestion list in VB when typing a type name after the As keyword (case=20261) 8257 * The text caret is placed in the correct location after accepting a .NET Generic from a suggestion list in VB 2008. (case=20259) 8257 * When typing a parameter in a C# LINQ predicate function, focus is no longer given to the suggestion list, matching the default VS 2008 behavior. (case=16277) * C++ keyword __restrict is recognized. (case=20732) 8307 * wmemset and wmemcpy are recognized as valid system functions. (case=18414) 7990 * Fixed a case where a managed assembly failed to be properly parsed. (case=20071) * VA Outline correctly displays C++ #pragma region/endregion nodes. (case=20612) 8274 * Multiline XML comments no longer contain extraneous '/' characters in VA Outline. (case=18539) 8005 * Document Method correctly handles array parameters when using the $MethodArgName$ VA Snippet variable. (case=20543) 8285 * Fixed problem in which enhanced coloring was not applied to Visual Studio text editor (due to certain color settings). (case=18813) 7993 * Fixed GDI resource leak that was exacerbated by the presence of an external clipboard manager utility. (case=20137) * Parameter Info tooltips for constructors of child classes render each parameter in bold correctly (fixes issue introduced in 1649). (case=20664) * VA Options | Performance | Rebuild Symbol databases causes the db files to be purged at IDE shutdown instead of the next startup (performance enhancement). (case=20799) 8319
1|)Security Wizard
Anyone that has set up Jet security on an application knows how difficult and confusing it can be. The Security Wizard is a tool that will allow you to setup your own security mechanism in your Access application without having to implement Jet security. Running the wizard from Tools/Add-ins/Security Add-In will copy several objects into your application. It will drop a table (tblOperators) into your application that will contains the list of users of your app and their password (passwords are encrypted using very simple XOR encryption.) Also, it will drop several modules, two class modules(GlobalProperties and SecurityClass) and one standard module (basMiscSecurityFunctions). (NOTE: The basMiscSecurityFunctions module has an IsLoaded function in it. If you already have an IsLoaded function in your application you will needed to delete if from the basMiscSecurityFunctions module. Delete the function only, not the whole module). Also, several forms are added to your project. Three of them (frmCreateUser, frmChangePassword, frmGetUserName) are used by the class module. The fourth form (frmEditUsers) can be used to manage the user accounts (make users administrators for example).
Once you run the Security wizards you add the following to the startup procedure of your application:
PWs.ConfirmPassword

Once the user logs in you can query there user name or authority using several GlobalProps properties as follows:
If GlobalProps.Administrator = True Then ...
or
If GlobalProps.CurrentUser = "JohnS" then ...

For more information the Security Add-In please click here or read the help file that is distributed with the wizards.

2) Global Error Handler
Error handling is a necessary evil of programming in ANY VB environment. All well-developed applications will have error handling code in most if not all of the procedures. The "evil" lies in the fact that VB does not add this error handling code for you. It only create the procedure "stub" (Sub...End Sub) for you so that it is up to the developer to add the error handling.
The Global Error Handler add-ins has two components. The first component, like the Security Add-In described above, adds all the objects that are needed to enable error handling and is installed from the Tools/Add-Ins/Global Error Handler menu item. This will add two(2) objects to your table: A table (usysErrors) which is the where all the errors are logged. (Yes - one of the features of thjs Add-In is that all errors get logged into this table which makes troubleshooting problems much easier.) And a module (basGlobalErrorHandler) which is procedure called by your handlers in order to handle and log the errors.

The second component is a "builder" that is installed by the setup routine. When you create a new procedure the builder will automatically add all of the error handling for it including the call to the Global Error Handler (which logs the error). To execute the builder, right click in the procedure and choose "Build" from the context menu. Now, instead of going straight to the Expression Builder, a selection box will appear. Choose "Global Error Handler" from the list and click OK. The error handling code will be automatically inserted into your procedure.

For more information on the Error Handling Add-Ins or error handling in general please click here or read the help file that is distributed with the wizards.

3)Many-to-Many Wizard
The Many-to-Many Add-In provides a way for developers to quickly and easily create forms that can be used to populate the junction table of a many-to-many table relationship. Normally, populating a junction table requires use of a Main-Form/Sub-Form interface with the junction table being populated by a Combo Box which is in the Sub-Form. (Don't know what I am talking about? Click HERE.) This kind of interface is extremely "kludgy" but it the only option available to non-programmers (unless they use some kind of Add-In such as the one described here.)
You start the Many-To-Many wizards (there are two of them) by selecting either Tools/Add-Ins/M2M CheckBox Wizard or Tools/Add-Ins/M2M ListBox Wizard from the menu. Each of these will step you through a wizard that will create a form for you (that you name at the end) that can then be used to populate the junction table with an form that is easy to use and intuitive. (NOTE: These wizards are the least tested of all of them and you probably WILL find bugs.)

For more information the Many-to-Many wizards or table relationships in general please click here or read the help file that is distributed with the wizards.

4) Name Builder
Microsoft Built-In wizards are very useful but they have one annoying flaw. That is, no naming conventions are used. Naming conventions are commonly used standards that all professional developers use to better manage their code and their projects. Even controls on forms should have standard naming conventions. For example, combo box usually begin with cbo (i.e., cboNames) and text boxes start with txt (i.e. txtAddress). When these conventions are used it makes managing the code associated with the controls easier.
The Microsoft wizards do NOT use these conventions. So when you create a form or report with the wizard, instead of "cboName" or "txtAddress" you get simply get "Name" or "Address". (This can cause some expressions to return #Name instead of the correct value, expecially in reports.) The problem is that it is difficult to remember the standard naming convention prefixes for controls and renaming them can be time consuming.

The Name Builder will correctly prefix a control with the right convention based on its type. To use it (the name builder is installed by the setup program) simply select the control and view its property sheet. Select the Name property from the property sheet. Click on the Build (...) button that is to the right of the property. It will take the current name that is in the property cell and replace it with the same value stripped of spaces and other undesirable text and prefixed with the right three letter convention.

Coming soon: A Name Builder wizard that will rename ALL controls on a new form using proper conventions. Send us an e-mail so that we can notify you when the change is available.


5) Linked Table Manager and other Wizards
Also included with the setup are a Linked Table Manager and other Add-Ins.

16,555

社区成员

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

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