Code help please :)

ok, let me start off by saying that it has been years since i have programmed using VB. so im trying to refresh my brain... here is my question.

I want to create a list and have it pulled up whenever i click a button..

What would my source code look like..

Thank you in advance!!
 
B4X:
Function Button1_onclick()
End Function

Dim Array1  
     Array1= Array    
          Item1="milk"        
          Item2="honey"    
          Item3="crackers"

So pretty much i want Button1_onclick() to put my Items there in a Textbox
im trying to figure this out methodically but not having any luck i have tried doing the following

B4X:
Function Button1_onclick()
Textbox1.value=array1
End Function

i have also tried

B4X:
Function Button1_onclick()
Dim Array1  
     Array1= Array    
          Item1="milk"        
          Item2="honey"    
          Item3="crackers"
Textbox1.value = Item1 + Item2 + Item3

End Function

however when i do get the items listed in my box... there is no carriage return, i have tried all the things i know such as vbCR vbLF vbCRLF
i have tried chr(10) chr(13).. nothing is working in this respect.
 
Upvote 0

admac231

Active Member
Licensed User
Longtime User
Have a look at this chunk of code:
B4X:
   Dim editText1 As EditText
   editText1.Initialize("editText1")
   Activity.AddView(editText1,0,0,100%x,150dip)
   editText1.SingleLine = False
   Dim arr(3) As String
   arr(0) = "milk"
   arr(1) = "honey"
   arr(2) = "crackers"
   editText1.Text = arr(0)&CRLF&arr(1)&CRLF&arr(2)

The most important thing to note is "editText1.SingleLine = False". This sets the textbox to multiline allowing the use of CRLF.
 
Upvote 0
ahhh i see what you are doing there :) ty for the help.. i will keep yall updated on my progress... all of your help is appreciated!! :sign0098:



but wait... isnt editText a java thing... what control am i using that on???
im not very good with java :p
 
Last edited:
Upvote 0
well how can i apply that to a VB control.. i mean VB doesnt have an EditText. and the textbox1 and textarea1 dont have a .text property
i just dont see how this applies at all to what im wanting to do.. perhaps if you explained further how this should help me :)

Thank you :)
 
Upvote 0

lagore

Active Member
Licensed User
Longtime User
Hi,
I would suggest you download one of the basic tutorial programs and work thru them, you seem to be mixing microsoft VB with B4A VB they are similar but you are getting the syntax mixed up.
 
Upvote 0

admac231

Active Member
Licensed User
Longtime User
Consider B4A as Java to VB, not VB to Java. That is, the syntax is VB but all properties, methods, fields etc are Java. That makes sense to me, I hope it does to you too!

EditText1.Text is the equivalent to TextBox1.Value. There is no textarea in B4A.

So, here's a chunk of code that does exactly what you originally asked:

B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim editText1 As EditText
   editText1.Initialize("editText1")
   Activity.AddView(editText1,0,0,100%x,10dip)
   editText1.SingleLine = False
   Dim arr(4) As String
   arr(0) = "milk"
   arr(1) = "honey"
   arr(2) = "crackers"
   arr(3) = "cheese"
   editText1.Text = arr(0)&CRLF&arr(1)&CRLF&arr(2)&CRLF&arr(3)
End Sub

As mentioned earlier in the thread, you really should work through the Beginners Guide
 
Upvote 0
Top