Lello1964 Well-Known Member Licensed User Longtime User Apr 7, 2020 #1 I have more edittext in main module: Main module : Code: dim EdiText01 as EditText dim EdiText02 as EditText dim EdiText03 as EditText dim EdiText04 as EditText ' etc... EdiText01.text = " text1" EdiText02.text = " text2" EdiText03.text = " text3" EdiText04.text = " text4" I must change text value from other Class Module My Module : Code: EdiText01.text = " Newtext1" EdiText02.text = " Newtext2" EdiText03.text = "New text3" EdiText04.text = " Newtext4" This code cannot work, but how can i do it ?
I have more edittext in main module: Main module : Code: dim EdiText01 as EditText dim EdiText02 as EditText dim EdiText03 as EditText dim EdiText04 as EditText ' etc... EdiText01.text = " text1" EdiText02.text = " text2" EdiText03.text = " text3" EdiText04.text = " text4" I must change text value from other Class Module My Module : Code: EdiText01.text = " Newtext1" EdiText02.text = " Newtext2" EdiText03.text = "New text3" EdiText04.text = " Newtext4" This code cannot work, but how can i do it ?
jahswant Well-Known Member Licensed User Longtime User Apr 7, 2020 #2 Create a sub in the Activity Module that will do the updates. Then when running your service use CallSub with update data and your texts will be updated. Upvote 0
Create a sub in the Activity Module that will do the updates. Then when running your service use CallSub with update data and your texts will be updated.
Lello1964 Well-Known Member Licensed User Longtime User Apr 7, 2020 #3 jahswani said: Create a sub in the Activity Module that will do the updates. Then when running your service use CallSub with update data and your texts will be updated. Click to expand... i know that, but i have many edit text to update. How pass edittext object and next edit text to main module ? for example callsub3(main,"UpdateEditText","EditText01","Newtext") ? Upvote 0
jahswani said: Create a sub in the Activity Module that will do the updates. Then when running your service use CallSub with update data and your texts will be updated. Click to expand... i know that, but i have many edit text to update. How pass edittext object and next edit text to main module ? for example callsub3(main,"UpdateEditText","EditText01","Newtext") ?
jahswant Well-Known Member Licensed User Longtime User Apr 7, 2020 #4 Prefer passing instead Strings to the Sub and Call Sub Upvote 0
josejad Expert Licensed User Longtime User Apr 7, 2020 #5 Follow this code: In your service, create an array with the EditText values, and pass the array as a parameter to your sub: CallSub with ANY number of parameters Sub CallSubX (Component As Object,SubName As String,Params() As Object) Dim no As NativeObject=Component Dim name As String=SubName Dim ll As List ll.Initialize2(Params) For i =0 To Params.Length-1 name=name & ":" Next... www.b4x.com Upvote 0
Follow this code: In your service, create an array with the EditText values, and pass the array as a parameter to your sub: CallSub with ANY number of parameters Sub CallSubX (Component As Object,SubName As String,Params() As Object) Dim no As NativeObject=Component Dim name As String=SubName Dim ll As List ll.Initialize2(Params) For i =0 To Params.Length-1 name=name & ":" Next... www.b4x.com
Lello1964 Well-Known Member Licensed User Longtime User Apr 7, 2020 #6 José J. Aguilar said: Follow this code: In your service, create an array with the EditText values, and pass the array as a parameter to your sub: CallSub with ANY number of parameters Sub CallSubX (Component As Object,SubName As String,Params() As Object) Dim no As NativeObject=Component Dim name As String=SubName Dim ll As List ll.Initialize2(Params) For i =0 To Params.Length-1 name=name & ":" Next... www.b4x.com Click to expand... I can't use array, i have more edit text. must pass object name and value. Upvote 0
José J. Aguilar said: Follow this code: In your service, create an array with the EditText values, and pass the array as a parameter to your sub: CallSub with ANY number of parameters Sub CallSubX (Component As Object,SubName As String,Params() As Object) Dim no As NativeObject=Component Dim name As String=SubName Dim ll As List ll.Initialize2(Params) For i =0 To Params.Length-1 name=name & ":" Next... www.b4x.com Click to expand... I can't use array, i have more edit text. must pass object name and value.
josejad Expert Licensed User Longtime User Apr 7, 2020 #7 Well, you can have an array of view (edittext) in your main module, and you can pass an array of values from you sub, as explained. Then, in you main sub, go through the array of edittext assigning the same position of the array of values Upvote 0
Well, you can have an array of view (edittext) in your main module, and you can pass an array of values from you sub, as explained. Then, in you main sub, go through the array of edittext assigning the same position of the array of values
Lello1964 Well-Known Member Licensed User Longtime User Apr 7, 2020 #8 José J. Aguilar said: Well, you can have an array of view (edittext) in your main module, and you can pass an array of values from you sub, as explained. Then, in you main sub, go through the array of edittext assigning the same position of the array of values Click to expand... Sorry, but i can't use array Code: dim EdiTextdddfd01 as EditText dim EdiTex4545t02 as EditText dim EdiTex454t03 as EditText dim EdiTex4545t04 as EditText this is an example Upvote 0
José J. Aguilar said: Well, you can have an array of view (edittext) in your main module, and you can pass an array of values from you sub, as explained. Then, in you main sub, go through the array of edittext assigning the same position of the array of values Click to expand... Sorry, but i can't use array Code: dim EdiTextdddfd01 as EditText dim EdiTex4545t02 as EditText dim EdiTex454t03 as EditText dim EdiTex4545t04 as EditText this is an example
josejad Expert Licensed User Longtime User Apr 7, 2020 #9 Lello1964 said: Sorry, but i can't use array Click to expand... Why? Sorry, but I can't see nothing in your example, just four EditText, so I don't understand why. Upvote 0
Lello1964 said: Sorry, but i can't use array Click to expand... Why? Sorry, but I can't see nothing in your example, just four EditText, so I don't understand why.
josejad Expert Licensed User Longtime User Apr 7, 2020 #10 Probably will be better solutions, but without knowing anything about your code. Maybe this can help Attachments array.zip array.zip 9.6 KB · Views: 385 Upvote 0
Lello1964 Well-Known Member Licensed User Longtime User Apr 7, 2020 #11 José J. Aguilar said: Probably will be better solutions, but without knowing anything about your code. Maybe this can help Click to expand... Thank for your help, but this solution don't solve my problem. I must change 1 editext at a time, and can't insert name in array. I'm looking for a solution to pass object name and value to a sub like : Code: callsub3(main,"UpdateEditText","EditText01","Newtext") where EditText01 is the object name in Main activity : for example : EdiText01 Newtext is the new text i don't know is there is a solution. Upvote 0
José J. Aguilar said: Probably will be better solutions, but without knowing anything about your code. Maybe this can help Click to expand... Thank for your help, but this solution don't solve my problem. I must change 1 editext at a time, and can't insert name in array. I'm looking for a solution to pass object name and value to a sub like : Code: callsub3(main,"UpdateEditText","EditText01","Newtext") where EditText01 is the object name in Main activity : for example : EdiText01 Newtext is the new text i don't know is there is a solution.
josejad Expert Licensed User Longtime User Apr 7, 2020 #12 Then, create the array, and pass in the sub the value and the index Upvote 0
Lello1964 Well-Known Member Licensed User Longtime User Apr 7, 2020 #13 José J. Aguilar said: Then, create the array, and pass in the sub the value and the index Click to expand... I can't put each edittext name in array, it's simply pass a id to change value. I must use this sub for many edittext and label. Upvote 0
José J. Aguilar said: Then, create the array, and pass in the sub the value and the index Click to expand... I can't put each edittext name in array, it's simply pass a id to change value. I must use this sub for many edittext and label.
R RJB Active Member Licensed User Longtime User Apr 8, 2020 #14 You have a problem as you can't refer to a view by name in this situation. If you are willing to use the edittext/ label tags then you could try the attached, modified from Jose's example. It's not very elegant and could be slow dependant on the number of views you have! Attachments array.zip array.zip 9.8 KB · Views: 368 Upvote 0
You have a problem as you can't refer to a view by name in this situation. If you are willing to use the edittext/ label tags then you could try the attached, modified from Jose's example. It's not very elegant and could be slow dependant on the number of views you have!
Lello1964 Well-Known Member Licensed User Longtime User Apr 8, 2020 #15 RJB said: You have a problem as you can't refer to a view by name in this situation. If you are willing to use the edittext/ label tags then you could try the attached, modified from Jose's example. It's not very elegant and could be slow dependant on the number of views you have! Click to expand... Thank for you help, but this isn't solution i'm looking for. Raffaele Upvote 0
RJB said: You have a problem as you can't refer to a view by name in this situation. If you are willing to use the edittext/ label tags then you could try the attached, modified from Jose's example. It's not very elegant and could be slow dependant on the number of views you have! Click to expand... Thank for you help, but this isn't solution i'm looking for. Raffaele
R RJB Active Member Licensed User Longtime User Apr 8, 2020 #16 Baffled as to what you are looking for then!! I thought you wanted to be able to set the text on an individual edittext/ label? What is it you want to do? Upvote 0
Baffled as to what you are looking for then!! I thought you wanted to be able to set the text on an individual edittext/ label? What is it you want to do?
Lello1964 Well-Known Member Licensed User Longtime User Apr 8, 2020 #17 RJB said: Baffled as to what you are looking for then!! I thought you wanted to be able to set the text on an individual edittext/ label? What is it you want to do? Click to expand... this : callsub3(main,"UpdateEditText","EditText01","Newtext") where EditText01 is the object name in Main activity : for example : EdiText01 Newtext is the new text I know that i can pass a tag or flag to a sub, but i want know is there is a way to pass editetext name as object, i can add any new edittext to main without add new tag. or id. Sorry is i'm not clear, my english isn't good. Upvote 0
RJB said: Baffled as to what you are looking for then!! I thought you wanted to be able to set the text on an individual edittext/ label? What is it you want to do? Click to expand... this : callsub3(main,"UpdateEditText","EditText01","Newtext") where EditText01 is the object name in Main activity : for example : EdiText01 Newtext is the new text I know that i can pass a tag or flag to a sub, but i want know is there is a way to pass editetext name as object, i can add any new edittext to main without add new tag. or id. Sorry is i'm not clear, my english isn't good.
R RJB Active Member Licensed User Longtime User Apr 8, 2020 #18 I guess you could have a sub for each view: Code: sub UpdateEditText01(TXT as string) edittext01.text = txt end sub sub UpdateEditText02(TXT as string) etc. but that could be a lot of subs. Or you could select the edittext: Code: sub UpdateEditText(ET as string, TXT as string) select case ET case "EditText01" edittext01.txt = TXT case "EditText02" etc. but again possible lots of 'cases' The real problem is that you can't refer to the view by name. That would make lots of things easier!! Last edited: Apr 8, 2020 Upvote 0
I guess you could have a sub for each view: Code: sub UpdateEditText01(TXT as string) edittext01.text = txt end sub sub UpdateEditText02(TXT as string) etc. but that could be a lot of subs. Or you could select the edittext: Code: sub UpdateEditText(ET as string, TXT as string) select case ET case "EditText01" edittext01.txt = TXT case "EditText02" etc. but again possible lots of 'cases' The real problem is that you can't refer to the view by name. That would make lots of things easier!!
Lello1964 Well-Known Member Licensed User Longtime User Apr 8, 2020 #19 RJB said: I guess you could have a sub for each view: Code: sub UpdateEditText01 Click to expand... If there isn't a solution, i will use Tag. Upvote 0
RJB said: I guess you could have a sub for each view: Code: sub UpdateEditText01 Click to expand... If there isn't a solution, i will use Tag.
Sagenut Expert Licensed User Longtime User Apr 8, 2020 #20 I don't know if I understood your need. Check this. *** EDIT *** Removed example. It was a Class, not a Service. Last edited: Apr 8, 2020 Upvote 0
I don't know if I understood your need. Check this. *** EDIT *** Removed example. It was a Class, not a Service.