내가 쓴 다음 코드:
Function find_results_idle()
Public iRaw As Integer
Public iColumn As Integer
iRaw = 1
iColumn = 1
그리고 난 내려받습니다 오류 메시지:
>. 잘못된 속성에 " 서브노드 또는 Function";
Do you know what I did 잘못된 것일까?
'글로벌' 대신 '있다' 고 전화했는데 사용할 수 있지만, attaboy 동일한 문제가 발생합니다.
이 함수를 선언할 수 있는 자신을 찾았다 'Public 이지만 did no good.
글로벌 변수 만들기 위해 무엇을 해야 합니까?
이 문제에 대해 <, a href = ", http://en.wikipedia.org/wiki/Scope_, , , /a> scope*&l > " (computer_science).
경우에만 다운로드하려는 변수를 사용하여 '흐림' 지난 수명입니다 함수의 함수나 변수를 선언할 서브노드 인사이드라면 (짧아 치수처리 ):
Function AddSomeNumbers() As Integer
Dim intA As Integer
Dim intB As Integer
intA = 2
intB = 3
AddSomeNumbers = intA + intB
End Function
'intA and intB are no longer available since the function ended
A 변수 (tpc. 슬레이크스 abc. 아웃하려면) 가 선언된 함수의 전역 바깥쪽인지가 사용하여 '있다' 고 키워드. 주기 동안 실행 중인 응용 프로그램 이 변수를 사용할 수 있습니다. 의 경우, 즉, 해당 Excel 엑셀 com/go/4e6b330a_kr 오더할 deltamove 워크북에서 열려 있다.
Public intA As Integer
Private intB As Integer
Function AddSomeNumbers() As Integer
intA = 2
intB = 3
AddSomeNumbers = intA + intB
End Function
'intA and intB are still both available. However, because intA is public, '
'it can also be referenced from code in other modules. Because intB is private,'
'it will be hidden from other modules.
단지 내에 접근할 수 있는 변수가 가질 수도 있습니다 (또는 클래스) 특정 모듈에서는 선언하여 함께 '개인' 키워드.
문제는 이 같은 다른 담당이잖아요 동일팔레트에 유효범위 관한 것입니다.
한마디로 이 고려해보십시오 module" ";:
Public Var1 As variant 'Var1 can be used in all
'modules, class modules and userforms of
'thisworkbook and will preserve any values
'assigned to it until either the workbook
'is closed or the project is reset.
Dim Var2 As Variant 'Var2 and Var3 can be used anywhere on the
Private Var3 As Variant ''current module and will preserve any values
''they're assigned until either the workbook
''is closed or the project is reset.
Sub MySub() 'Var4 can only be used within the procedure MySub
Dim Var4 as Variant ''and will only store values until the procedure
End Sub ''ends.
Sub MyOtherSub() 'You can even declare another Var4 within a
Dim Var4 as Variant ''different procedure without generating an
End Sub ''error (only possible confusion).
이 [MSDN 참조] 체크아웃하려고 수 있습니다 (https://msdn.microsoft.com/en-us/library/office/gg264241.aspx Variables" 선언 ";) 이 방법은 변수 선언 및 다른 [스택 오버플로입니다 질문] (https://stackoverflow.com/questions/19038350/when-should-an-excel-vba-variable-be-killed-or-set-to-nothing " 경우, Excel VBA 가변으로 할 수 있는 사망하거나 설정되었습니다 " 아무것도요?;) 아웃해야 내시경이요 검색하기를 com/go/4e6b330a_kr 방법에 대한 자세한
다른 두 신속시작 창조하셨노:
만약 이 기능을 사용할 수 있는 모듈에서는 그냥 쓰기 때문에 그 함수의 바깥쪽인지가 / 클래스 '는 글로벌 유효범위'. 이는 글로벌 유효범위 가변적입니다 https://learning. 다른 함수에 의해 같은 모듈에서는 / 클래스 (사용할 경우 '흐림' 으로 선언문의, 사용 '있다' 고 스케쳐내 https://learning. 변수는 모든 기능을 통해 모든 모듈):
Dim iRaw As Integer
Dim iColumn As Integer
Function find_results_idle()
iRaw = 1
iColumn = 1
End Function
Function this_can_access_global()
iRaw = 2
iColumn = 2
End Function
만드시겠습니까 integer 의 일반 공개 선언.
그 때마다 해당 기능을 그 가치를 높일 수 있습니다. 예 (함수) 의 csv 로 e-메일입니다 저장하라는 액세서리 포함).
Public Numerator As Integer
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim FileName As String
saveFolder = "c:\temp\"
For Each objAtt In itm.Attachments
FileName = objAtt.DisplayName & "_" & Numerator & "_" & Format(Now, "yyyy-mm-dd H-mm-ss") & ".CSV"
objAtt.SaveAsFile saveFolder & "\" & FileName
Numerator = Numerator + 1
Set objAtt = Nothing
Next
End Sub
좋은 공개 / 전역 변수를 만들 수 있는 방법이 양식을 사용하여 치료할 수 있다 (like a 클래스를 선언하고 객체에는 액세스하려면 속성 속성 및 공물 프레젠테이션이든 [가변으로] / 메서드입니다. 또한 참조입니다 대한 참조입니다 모듈에서는 인스턴스화되지 양식 또는 성공 할 수 있습니다. 양식 / 보도에 종료되었는지 전화하시기 방법을 경우 오류를 얻게 됩니다. 예: 메드포르마리모두리스파렌트 전달하십시오 salesforce. 서브노드 / 기능 없는 δ1 양식.
Option Compare Database
Option Explicit
''***********************************''
' Name: Date: Created Date Author: Name
' Current Version: 1.0
' Called by:
''***********************************''
' Notes: Explain Who what when why...
' This code Example requires properties to be filled in
''***********************************''
' Global Variables
Public GlobalData As Variant
''***********************************''
' Private Variables
Private ObjectReference As Object
Private ExampleVariable As Variant
Private ExampleData As Variant
''***********************************''
' Public properties
Public Property Get ObjectVariable() As Object
Set ObjectVariable = ObjectReference
End Property
Public Property Get Variable1() As Variant
'Recommend using variants to avoid data errors
Variable1 = ExampleVariable
End property
''***********************************''
' Public Functions that return values
Public Function DataReturn (Input As Variant) As Variant
DataReturn = ExampleData + Input
End Function
''***********************************''
' Public Sub Routines
Public Sub GlobalMethod()
'call local Functions/Subs outside of form
Me.Form.Refresh
End Sub
''***********************************''
' Private Functions/Subs used not visible outside
''***********************************''
End Code
그래서 당신이 약간만이라도 또 다른 모듈에서는 액세스할 수 있습니다.
Public Sub Method1(objForm as Object)
'read/write data value
objForm.GlobalData
'Get object reference (need to add Public Property Set to change reference object)
objForm.ObjectVariable
'read only (needs Public property Let to change value)
objForm.Variable1
'Gets result of function with input
objForm.DataReturn([Input])
'runs sub/function from outside of normal scope
objForm.GlobalMethod
End Sub
항상 같은 값을 사용하는 경우 바인딩하면 말 나는한다 확인할지 nulll 객체에는 아무것도아니야 시도하기 전에 처리 및 수행합니다.