你可以在项目中找到program.cs文件,其中有这么一段代码
创新互联专注于清流企业网站建设,自适应网站建设,商城网站建设。清流网站建设公司,为清流等地区提供建站服务。全流程定制制作,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务
static
class
program
{
///
///
应用程序的主入口点。
///
[stathread]
static
void
main()
{
application.enablevisualstyles();
application.setcompatibletextrenderingdefault(false);
application.run(new
infocenterform());
}
}
你只要修改最后一行代码,application.run(new
infocenterform());,修改为你要启动的窗体就可以了
commondialog控件只能选择文件,不能选择文件夹,用下面的代码可以选文件夹:
Option Explicit
Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Const BIF_RETURNONLYFSDIRS = 1
Const MAX_PATH = 260
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Public Function BrowseForFolder(Optional sTitle As String = "请选择文件夹") As String
Dim iNull As Integer, lpIDList As Long, lResult As Long
Dim sPath As String, udtBI As BrowseInfo
With udtBI
.hWndOwner = 0 ' Me.hWnd
.lpszTitle = lstrcat(sTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With
lpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
sPath = String$(MAX_PATH, 0)
SHGetPathFromIDList lpIDList, sPath
CoTaskMemFree lpIDList
iNull = InStr(sPath, vbNullChar)
If iNull Then
sPath = Left$(sPath, iNull - 1)
End If
End If
BrowseForFolder = sPath
End Function
Private Sub Command1_Click()
MsgBox BrowseForFolder()
End Sub
vb.net生成的exe文件要在没有安装vb的电脑上运行是可以的,但有条件:
1.
要安装
.net
framework2.0或以上版本,然后就可以直接运行exe
2.
利用vb打包项目,生成可安装的exe文件或绿色直接可执行的exe文件
3.
不喜欢vb6可以删除之,但必须再安装同类型的.net的ide产品后也可以