Italian Passare esempio EditText1 a un modulo

Spinter

Active Member
Licensed User
Longtime User
come posso passare una EditText a un modulo?

Ho provato:

me.EditText.text =
main.EditText,text=

ma non mi funziona,si puo fare?

grazie!
 

ivanomonti

Expert
Licensed User
Longtime User
come posso passare una EditText a un modulo?

Ho provato:

me.EditText.text =
main.EditText,text=

ma non mi funziona,si puo fare?

grazie!

sul modulo

B4X:
dim et as editetext

in activity

B4X:
modulo.et = main.editText1

Soluzione

et dichiarato nel modulo diventa un puntatore di main.EditText ... questo significa che ogni cambiamento in uno dei due cambia il suo status.

Se invece vuoi passare solo il contenuto

in modulo

B4X:
dim et as string

in activity

B4X:
modulo.et = main.editText1.text

Spero possa darti la soluzione richiesta.
 

arenaluigi

Well-Known Member
Licensed User
Longtime User
come posso passare una EditText a un modulo?

Ho provato:

me.EditText.text =
main.EditText,text=

ma non mi funziona,si puo fare?

grazie!
Vuoi passare l'oggetto edittext oppure il testo scritto in una edittext ?
A me non è chiaro:sign0013:
 

Spinter

Active Member
Licensed User
Longtime User
Forse mi son spiegato male!Forse continuro' a spigarmi male scusate!

Io ho bisogno di poter vedere la oggetto editbox in un modulo.

nel activity ho la mia editbox1 dichiarata

ma se nel modulo la scrivo con me or main mi da errore di compilazione!


Compiling code. Error
Error parsing program.
Error description: Undeclared variable 'editbox1' is used before it was assigned any value.
Occurred on line: 80
editbox1.Clear
 
Last edited:

Gianni M

Well-Known Member
Licensed User
Longtime User
Forse mi son spiegato male!Forse continuro' a spigarmi male scusate!

... allega un po di codice. aiuta te e noi a risolvere prima! ;)
 

Spinter

Active Member
Licensed User
Longtime User
B4X:
Sub Process_Globals

End Sub

Sub Globals
   
   Dim EditText1 As EditText
   Dim Button1 As Button
   
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("c")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
la.semplice
End Sub


Modulo si chiama la:
B4X:
'Code module
'Subs in this code module will be accessible from all modules.
Public Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
End Sub


Sub semplice 

EditText1.text="CIAO"

End Sub
 
Last edited:

ivanomonti

Expert
Licensed User
Longtime User
B4X:
Sub Process_Globals

End Sub

Sub Globals
   
   Dim EditText1 As EditText
   Dim Button1 As Button
   
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("c")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
la.semplice
End Sub


Modulo si chiama la:
B4X:
'Code module
'Subs in this code module will be accessible from all modules.
Public Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
End Sub


Sub semplice 
[COLOR="red"]EditText1.text[/COLOR]
End Sub

scusa ok che vuoi passare il testo contenuto della EditText ma dove e perchè ...


B4X:
Sub Button1_Click
  msgBox(la.semplice,"") 
End Sub
vedrai che funziona, ma non ha senso l'uso, altrimenti passi object

B4X:
Sub Button1_Click
   msgBox(la.semplice(EditText1,"") 
End Sub

B4X:
Sub semplice (t as EditText) as string
   return t.text
End Sub
 

ivanomonti

Expert
Licensed User
Longtime User
è solo un semplice esempio niente di più!!

per creare delle funzioni!

Si ma devono avere un senso anche se poi non le usi

modulo la

B4X:
sub semplice( t as text ) as string

dim result as string

if t = pirla then
 resutl = "P...a"
else
 result ="ok"
end if

return result

end sub

B4X:
sub Button1_Click()
 MsgBox la.semplece("P...a")
end sub


or

B4X:
sub Button1_click()
 MsgBox la.semplice(EditText.text)
end sub



hahahaahh e solo un esempio
 
Last edited:

ivanomonti

Expert
Licensed User
Longtime User
Scusa ma io non ho fatto il maleducato!!!!
Io ho chiesto solo se si può fare?

Chiedo scusa, ma quando ho scritto questo ero allegro hahahah, perdonami, il pirla poi non era rivolto a te, ma a me stesso.

Chiedo scusa a tutta la ML.
 

klaus

Expert
Licensed User
Longtime User
There is something strange in your explanations, in your post#1 you are referencing to EditText.
In post #4 the error message says 'editbox1' .
How and where did you declare the EditText and with what name ?

Basically you cannot acces directly an activity object like an EditText view from another module.
What you can do is to pass the object as a parameter in the calling routine.
Attached a small test program showing it.
Main module:
B4X:
Sub Globals
    'These variables can only be accessed from this module.
    Dim edtTest As EditText
    Dim btnTest As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    btnTest.Initialize("btnTest")
    Activity.AddView(btnTest, 50dip, 50dip, 150dip, 50dip)
    btnTest.Text = "Add text"
    edtTest.Initialize("edtTest")
    Activity.AddView(edtTest, 10dip, 150dip, 300dip, 50dip)
    edtTest.Text = "Test"
End Sub

Sub btnTest_Click
    Test.AddText(edtTest, " added text")
End Sub
Test code module:
B4X:
'Test Code module
Sub Process_Globals

End Sub

Sub AddText(edt As EditText, txt As String)
    edt.Text = edt.Text & txt
End Sub
Best regards.
 

Attachments

  • EditTextInModule.zip
    5.8 KB · Views: 329

Spinter

Active Member
Licensed User
Longtime User
Grazie ragazzi per l'aiuto tranquilli io non sono arrabiato ,comunque penso che quando uno risponde a un aiuto merita un grazie,io purtroppo spesso non so spiegarmi bene ,e per questo mi scuso!
 
Top