Toon posts:

[VBA] variabele van form naar module en terug

Pagina: 1
Acties:

Verwijderd

Topicstarter
Het volgende
Ik heb een form met een txt control (txtTemp) daarop.
Nu roep ik vanaf event change van deze control de module myCheck aan.
code:
sub txtTemp_change()
call MyMacros.myCheck(txtTemp.value)
msgbox varTemp
end sub

sub myCheck(varTemp)
if len(varTemp) > 5 then
varTemp = "test > 5"
else
varTemp = "test other than 5"
end if
end Sub

het gekke is dat msgbox in txtTemp_change simpelweg leeg blijft??
Ik heb al zitten stoeien met Public varTemp as string en dat soort zkaen maar dat helpt ook niet??
Ik krijg het dus niet voor elkaar een variabele terug te gooien van de module naar het coontrol???

Wie kan mij even op weg helpen....
Tnx,....

  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 00:45

Creepy

Tactical Espionage Splatterer

eeh.. varTemp is alleen bekend in myCheck. Nogal logisch dat je die niet kan benaderen in txtTemp_change).
Waarom geef je varTemp niet als resultaat van myCheck() terug?

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney


  • NMe
  • Registratie: Februari 2004
  • Laatst online: 19-08 12:58

NMe

Quia Ego Sic Dico.

Ik heb je vorige VBA-topic ook al van Programming & Webscripting naar Officesuites en -software moeten moven...

PW>>OFF

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


  • mulder
  • Registratie: Augustus 2001
  • Laatst online: 22-08 10:45

mulder

ik spuug op het trottoir

Google maar eens op ByVal en ByRef en op variable scope


... en Option Explicit!

oogjes open, snaveltjes dicht


Verwijderd

Topicstarter
sorry MOD...old habit :)
zal er rekening mee houden...

  • Daos
  • Registratie: Oktober 2004
  • Niet online
Je kan ook een functie maken:
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
Sub txtTemp_change()
    varTemp = MyMacros.myCheck(txtTemp.Value)
    MsgBox varTemp
End Sub

Function myCheck(varTemp)
    If Len(varTemp) > 5 Then
        myCheck = "test > 5"
    Else
        myCheck = "test other than 5"
    End If
End Function


edit:
spuit11...

[ Voor 17% gewijzigd door Daos op 20-07-2005 17:45 ]

Pagina: 1