I have a series of textfields that I want to print to an output string. I am using the below code:
Dim accounts() As String = Array("’" + TextField1.text + “’, '” + TextField2.text + “’, '” + TextField3.text + “’, '” + TextField4.text + “’”)
For Each user As String In accounts
output = output + user
if user = “” Then
output = output + user
end if
Next
but when it prints out the text string, it still puts the commas into the output string. I would like to just have the text strings put in without the empty spaces and following commas.
You shouldn’t put quotes between the TextFields in the array.
Dim fields() as TextField = Array(TextField1, TextField2...)
Dim user as String
Dim output as String
For each txtF as TextField in fields
user = txtF.text
output = output + user
if user = "" Then
output = output + user
end if
Next
Thanks for the quick reply. Your sample is almost where I need to be. But I am in need of the comma after a textfield that is not empty. How would I accomplish that task?
Dim fields() as TextField = Array(TextField1, TextField2...)
Dim tmpOutput() As String
Dim output as String
For each txtF as TextField in fields
user = txtF.text
if user <> "" then
tmpOutput.Append user
End if
Next
output = Join(tmpOutput, ",")