26 个解决方案
#1
添加一个标准模块,在模块顶声明变量
Global MYPATH As String
在该模块中添加过程(过程序名必须是Main)
Sub Main()
MYPATH="D:\"
Form1.show'就是你第一个要显示的窗体
End sub
然后到“工程”的“属性”窗口把启动选择到Sub Main
这样就能达到你的要求了。
Global MYPATH As String
在该模块中添加过程(过程序名必须是Main)
Sub Main()
MYPATH="D:\"
Form1.show'就是你第一个要显示的窗体
End sub
然后到“工程”的“属性”窗口把启动选择到Sub Main
这样就能达到你的要求了。
#2
全局变量可以在 sub mian 中初始.
没有使用 sub mian的话,在窗体的load中初始
#3
只要定義時使用public就可以了
比如變量為字符型時
public myvalue as string
比如變量為字符型時
public myvalue as string
#4
在模块中定义为
public A as string
你可以在sub main中初始化——这是最早的了,另外在任何一个合适地方的初始化也是可以的
sub main
a="123"
end sub
public A as string
你可以在sub main中初始化——这是最早的了,另外在任何一个合适地方的初始化也是可以的
sub main
a="123"
end sub
#5
模块中定义
public Vars as string
如果用sub main 启动的话,就在sub main中将其负值,
如果用form_load启动的话,就在那里负值不就行吗。
public Vars as string
如果用sub main 启动的话,就在sub main中将其负值,
如果用form_load启动的话,就在那里负值不就行吗。
#6
定义全局变量
Public uExitHandle As Long
定义全局常量
Global Const Process_info = &H400
全局变量可以在窗体Form_load中定义也可以在sub main函数中定义
Public uExitHandle As Long
定义全局常量
Global Const Process_info = &H400
全局变量可以在窗体Form_load中定义也可以在sub main函数中定义
#7
各位大虾,如果是定义一个全局的静态数组,并在其定义的时候就初始化,应该怎么办啊?
#8
初始化成什么值?
Public Sub SetDiShi()
'***************
'初始化
aryDiShi(0, 0) = "QS"
aryDiShi(0, 1) = "全省所有考点列表"
aryDiShi(1, 0) = "JN"
aryDiShi(1, 1) = "济南"
aryDiShi(2, 0) = "QD"
aryDiShi(2, 1) = "青岛"
aryDiShi(3, 0) = "ZB"
aryDiShi(3, 1) = "淄博"
aryDiShi(4, 0) = "ZZ"
aryDiShi(4, 1) = "枣庄"
aryDiShi(5, 0) = "DY"
aryDiShi(5, 1) = "东营"
aryDiShi(6, 0) = "YT"
aryDiShi(6, 1) = "烟台"
aryDiShi(7, 0) = "WF"
aryDiShi(7, 1) = "潍坊"
aryDiShi(8, 0) = "JM"
aryDiShi(8, 1) = "济宁"
aryDiShi(9, 0) = "TA"
aryDiShi(9, 1) = "泰安"
aryDiShi(10, 0) = "WH"
aryDiShi(10, 1) = "威海"
aryDiShi(11, 0) = "RZ"
aryDiShi(11, 1) = "日照"
aryDiShi(12, 0) = "LW"
aryDiShi(12, 1) = "莱芜"
aryDiShi(13, 0) = "LY"
aryDiShi(13, 1) = "临沂"
aryDiShi(14, 0) = "DZ"
aryDiShi(14, 1) = "德州"
aryDiShi(15, 0) = "LC"
aryDiShi(15, 1) = "聊城"
aryDiShi(16, 0) = "BZ"
aryDiShi(16, 1) = "滨州"
aryDiShi(17, 0) = "HZ"
aryDiShi(17, 1) = "菏泽"
End Sub
是这样吗?
Public Sub SetDiShi()
'***************
'初始化
aryDiShi(0, 0) = "QS"
aryDiShi(0, 1) = "全省所有考点列表"
aryDiShi(1, 0) = "JN"
aryDiShi(1, 1) = "济南"
aryDiShi(2, 0) = "QD"
aryDiShi(2, 1) = "青岛"
aryDiShi(3, 0) = "ZB"
aryDiShi(3, 1) = "淄博"
aryDiShi(4, 0) = "ZZ"
aryDiShi(4, 1) = "枣庄"
aryDiShi(5, 0) = "DY"
aryDiShi(5, 1) = "东营"
aryDiShi(6, 0) = "YT"
aryDiShi(6, 1) = "烟台"
aryDiShi(7, 0) = "WF"
aryDiShi(7, 1) = "潍坊"
aryDiShi(8, 0) = "JM"
aryDiShi(8, 1) = "济宁"
aryDiShi(9, 0) = "TA"
aryDiShi(9, 1) = "泰安"
aryDiShi(10, 0) = "WH"
aryDiShi(10, 1) = "威海"
aryDiShi(11, 0) = "RZ"
aryDiShi(11, 1) = "日照"
aryDiShi(12, 0) = "LW"
aryDiShi(12, 1) = "莱芜"
aryDiShi(13, 0) = "LY"
aryDiShi(13, 1) = "临沂"
aryDiShi(14, 0) = "DZ"
aryDiShi(14, 1) = "德州"
aryDiShi(15, 0) = "LC"
aryDiShi(15, 1) = "聊城"
aryDiShi(16, 0) = "BZ"
aryDiShi(16, 1) = "滨州"
aryDiShi(17, 0) = "HZ"
aryDiShi(17, 1) = "菏泽"
End Sub
是这样吗?
#9
楼上,我希望不是在过程或函数中进行初始化,我的意思就是相当于定义一个常量,类似于c语言中的静态变量。不知道应该怎么实现?
#10
Public Const TITLE_PG = "日発システム"
#11
#12
Private Sub Command10_Click()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnn = New ADODB.Connection
' 引用 ODBC driver 建立连接.
cnn.ConnectionString = "driver={SQL Server};" & _
"server=dcser;uid=sa;pwd=;database=stxt"
cnn.Open
adoConnection.Execute "Update Rs Set QQTS = 0" 请问这句要怎么改呢?
错误信息424 要求对象
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnn = New ADODB.Connection
' 引用 ODBC driver 建立连接.
cnn.ConnectionString = "driver={SQL Server};" & _
"server=dcser;uid=sa;pwd=;database=stxt"
cnn.Open
adoConnection.Execute "Update Rs Set QQTS = 0" 请问这句要怎么改呢?
错误信息424 要求对象
#13
cnn.Execute "Update Rs Set QQTS = 0" 搞定
#14
up
#15
定义常量的方法
public const C_NAME="1234"
public const C_NAME="1234"
#16
我想可能使我没有说清楚,我的意思是:
在.bas中定义一个全局变量,而这个变量是一个数组类型,我想在定义的时候就将其初始化,就跟c语言中的静态全局数组一样,请问应该如何定义或是实现啊?
在.bas中定义一个全局变量,而这个变量是一个数组类型,我想在定义的时候就将其初始化,就跟c语言中的静态全局数组一样,请问应该如何定义或是实现啊?
#17
dim sString
sString=Array("113","234","567",678")
sString=Array("113","234","567",678")
#18
你可以使用动态数组。可以在使用数组前初始化它。
#19
楼上,还是不行啊,我这样子写的,运行时说在模块外初始化无效阿
我把我写的代码贴出来,大家帮忙看看
Option Explicit
'**********************************************************************************
'* Error settings *
'**********************************************************************************
'The Global Error Handle
Private g_hError As Integer
Private ErrMaps() As String
Private g_bInitialed As Boolean
'这是出错的地方:
ErrMaps = Array("113", "234", "567", "678")
我把我写的代码贴出来,大家帮忙看看
Option Explicit
'**********************************************************************************
'* Error settings *
'**********************************************************************************
'The Global Error Handle
Private g_hError As Integer
Private ErrMaps() As String
Private g_bInitialed As Boolean
'这是出错的地方:
ErrMaps = Array("113", "234", "567", "678")
#20
要把:
ErrMaps = Array("113", "234", "567", "678")
放到sub main中
直接放到外部不行,或者变通一下,使用枚举类型:
Enum test
test1 = 1
test2 = 22
test3 = 33
test4 = 112
End Enum
ErrMaps = Array("113", "234", "567", "678")
放到sub main中
直接放到外部不行,或者变通一下,使用枚举类型:
Enum test
test1 = 1
test2 = 22
test3 = 33
test4 = 112
End Enum
#21
我知道把上面的代码放在过程或者是方法当中是可行的,但是我希望把全局变量定义为一个数组常量,定义好之后,不需要人为的进行初始化阿。不知道应该怎么实现?
#22
定义全局常量
Global Const Process_info = &H400
Global Const Process_info = &H400
#23
BAS:
Public Const ALL = "123,456,789,ABC,XYZ"
FORM1:
Dim A() As String
Private Sub Command1_Click()
A = Split(ALL, ",")
MsgBox A(2)
End Sub
Public Const ALL = "123,456,789,ABC,XYZ"
FORM1:
Dim A() As String
Private Sub Command1_Click()
A = Split(ALL, ",")
MsgBox A(2)
End Sub
#24
路过
#25
就这点事用这么多人重复吗
#26
在定義完後直接賦值不就可以了.為什麼還要放到sub main()中呢.
#1
添加一个标准模块,在模块顶声明变量
Global MYPATH As String
在该模块中添加过程(过程序名必须是Main)
Sub Main()
MYPATH="D:\"
Form1.show'就是你第一个要显示的窗体
End sub
然后到“工程”的“属性”窗口把启动选择到Sub Main
这样就能达到你的要求了。
Global MYPATH As String
在该模块中添加过程(过程序名必须是Main)
Sub Main()
MYPATH="D:\"
Form1.show'就是你第一个要显示的窗体
End sub
然后到“工程”的“属性”窗口把启动选择到Sub Main
这样就能达到你的要求了。
#2
全局变量可以在 sub mian 中初始.
没有使用 sub mian的话,在窗体的load中初始
#3
只要定義時使用public就可以了
比如變量為字符型時
public myvalue as string
比如變量為字符型時
public myvalue as string
#4
在模块中定义为
public A as string
你可以在sub main中初始化——这是最早的了,另外在任何一个合适地方的初始化也是可以的
sub main
a="123"
end sub
public A as string
你可以在sub main中初始化——这是最早的了,另外在任何一个合适地方的初始化也是可以的
sub main
a="123"
end sub
#5
模块中定义
public Vars as string
如果用sub main 启动的话,就在sub main中将其负值,
如果用form_load启动的话,就在那里负值不就行吗。
public Vars as string
如果用sub main 启动的话,就在sub main中将其负值,
如果用form_load启动的话,就在那里负值不就行吗。
#6
定义全局变量
Public uExitHandle As Long
定义全局常量
Global Const Process_info = &H400
全局变量可以在窗体Form_load中定义也可以在sub main函数中定义
Public uExitHandle As Long
定义全局常量
Global Const Process_info = &H400
全局变量可以在窗体Form_load中定义也可以在sub main函数中定义
#7
各位大虾,如果是定义一个全局的静态数组,并在其定义的时候就初始化,应该怎么办啊?
#8
初始化成什么值?
Public Sub SetDiShi()
'***************
'初始化
aryDiShi(0, 0) = "QS"
aryDiShi(0, 1) = "全省所有考点列表"
aryDiShi(1, 0) = "JN"
aryDiShi(1, 1) = "济南"
aryDiShi(2, 0) = "QD"
aryDiShi(2, 1) = "青岛"
aryDiShi(3, 0) = "ZB"
aryDiShi(3, 1) = "淄博"
aryDiShi(4, 0) = "ZZ"
aryDiShi(4, 1) = "枣庄"
aryDiShi(5, 0) = "DY"
aryDiShi(5, 1) = "东营"
aryDiShi(6, 0) = "YT"
aryDiShi(6, 1) = "烟台"
aryDiShi(7, 0) = "WF"
aryDiShi(7, 1) = "潍坊"
aryDiShi(8, 0) = "JM"
aryDiShi(8, 1) = "济宁"
aryDiShi(9, 0) = "TA"
aryDiShi(9, 1) = "泰安"
aryDiShi(10, 0) = "WH"
aryDiShi(10, 1) = "威海"
aryDiShi(11, 0) = "RZ"
aryDiShi(11, 1) = "日照"
aryDiShi(12, 0) = "LW"
aryDiShi(12, 1) = "莱芜"
aryDiShi(13, 0) = "LY"
aryDiShi(13, 1) = "临沂"
aryDiShi(14, 0) = "DZ"
aryDiShi(14, 1) = "德州"
aryDiShi(15, 0) = "LC"
aryDiShi(15, 1) = "聊城"
aryDiShi(16, 0) = "BZ"
aryDiShi(16, 1) = "滨州"
aryDiShi(17, 0) = "HZ"
aryDiShi(17, 1) = "菏泽"
End Sub
是这样吗?
Public Sub SetDiShi()
'***************
'初始化
aryDiShi(0, 0) = "QS"
aryDiShi(0, 1) = "全省所有考点列表"
aryDiShi(1, 0) = "JN"
aryDiShi(1, 1) = "济南"
aryDiShi(2, 0) = "QD"
aryDiShi(2, 1) = "青岛"
aryDiShi(3, 0) = "ZB"
aryDiShi(3, 1) = "淄博"
aryDiShi(4, 0) = "ZZ"
aryDiShi(4, 1) = "枣庄"
aryDiShi(5, 0) = "DY"
aryDiShi(5, 1) = "东营"
aryDiShi(6, 0) = "YT"
aryDiShi(6, 1) = "烟台"
aryDiShi(7, 0) = "WF"
aryDiShi(7, 1) = "潍坊"
aryDiShi(8, 0) = "JM"
aryDiShi(8, 1) = "济宁"
aryDiShi(9, 0) = "TA"
aryDiShi(9, 1) = "泰安"
aryDiShi(10, 0) = "WH"
aryDiShi(10, 1) = "威海"
aryDiShi(11, 0) = "RZ"
aryDiShi(11, 1) = "日照"
aryDiShi(12, 0) = "LW"
aryDiShi(12, 1) = "莱芜"
aryDiShi(13, 0) = "LY"
aryDiShi(13, 1) = "临沂"
aryDiShi(14, 0) = "DZ"
aryDiShi(14, 1) = "德州"
aryDiShi(15, 0) = "LC"
aryDiShi(15, 1) = "聊城"
aryDiShi(16, 0) = "BZ"
aryDiShi(16, 1) = "滨州"
aryDiShi(17, 0) = "HZ"
aryDiShi(17, 1) = "菏泽"
End Sub
是这样吗?
#9
楼上,我希望不是在过程或函数中进行初始化,我的意思就是相当于定义一个常量,类似于c语言中的静态变量。不知道应该怎么实现?
#10
Public Const TITLE_PG = "日発システム"
#11
#12
Private Sub Command10_Click()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnn = New ADODB.Connection
' 引用 ODBC driver 建立连接.
cnn.ConnectionString = "driver={SQL Server};" & _
"server=dcser;uid=sa;pwd=;database=stxt"
cnn.Open
adoConnection.Execute "Update Rs Set QQTS = 0" 请问这句要怎么改呢?
错误信息424 要求对象
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnn = New ADODB.Connection
' 引用 ODBC driver 建立连接.
cnn.ConnectionString = "driver={SQL Server};" & _
"server=dcser;uid=sa;pwd=;database=stxt"
cnn.Open
adoConnection.Execute "Update Rs Set QQTS = 0" 请问这句要怎么改呢?
错误信息424 要求对象
#13
cnn.Execute "Update Rs Set QQTS = 0" 搞定
#14
up
#15
定义常量的方法
public const C_NAME="1234"
public const C_NAME="1234"
#16
我想可能使我没有说清楚,我的意思是:
在.bas中定义一个全局变量,而这个变量是一个数组类型,我想在定义的时候就将其初始化,就跟c语言中的静态全局数组一样,请问应该如何定义或是实现啊?
在.bas中定义一个全局变量,而这个变量是一个数组类型,我想在定义的时候就将其初始化,就跟c语言中的静态全局数组一样,请问应该如何定义或是实现啊?
#17
dim sString
sString=Array("113","234","567",678")
sString=Array("113","234","567",678")
#18
你可以使用动态数组。可以在使用数组前初始化它。
#19
楼上,还是不行啊,我这样子写的,运行时说在模块外初始化无效阿
我把我写的代码贴出来,大家帮忙看看
Option Explicit
'**********************************************************************************
'* Error settings *
'**********************************************************************************
'The Global Error Handle
Private g_hError As Integer
Private ErrMaps() As String
Private g_bInitialed As Boolean
'这是出错的地方:
ErrMaps = Array("113", "234", "567", "678")
我把我写的代码贴出来,大家帮忙看看
Option Explicit
'**********************************************************************************
'* Error settings *
'**********************************************************************************
'The Global Error Handle
Private g_hError As Integer
Private ErrMaps() As String
Private g_bInitialed As Boolean
'这是出错的地方:
ErrMaps = Array("113", "234", "567", "678")
#20
要把:
ErrMaps = Array("113", "234", "567", "678")
放到sub main中
直接放到外部不行,或者变通一下,使用枚举类型:
Enum test
test1 = 1
test2 = 22
test3 = 33
test4 = 112
End Enum
ErrMaps = Array("113", "234", "567", "678")
放到sub main中
直接放到外部不行,或者变通一下,使用枚举类型:
Enum test
test1 = 1
test2 = 22
test3 = 33
test4 = 112
End Enum
#21
我知道把上面的代码放在过程或者是方法当中是可行的,但是我希望把全局变量定义为一个数组常量,定义好之后,不需要人为的进行初始化阿。不知道应该怎么实现?
#22
定义全局常量
Global Const Process_info = &H400
Global Const Process_info = &H400
#23
BAS:
Public Const ALL = "123,456,789,ABC,XYZ"
FORM1:
Dim A() As String
Private Sub Command1_Click()
A = Split(ALL, ",")
MsgBox A(2)
End Sub
Public Const ALL = "123,456,789,ABC,XYZ"
FORM1:
Dim A() As String
Private Sub Command1_Click()
A = Split(ALL, ",")
MsgBox A(2)
End Sub
#24
路过
#25
就这点事用这么多人重复吗
#26
在定義完後直接賦值不就可以了.為什麼還要放到sub main()中呢.