Android Question Check if string exists

kostakost

Member
Hello!
I'm trying to call a string, but there may not be such a string.
Is it possible this exception be handled progammatically instead of being unable to build?
Here's an example:

B4X:
Sub Process_Globals
     Public String1 as String = "This is string1"
     Public String2 as String = "This is string2"
     Public String3 as String = "This is string3"
     Public String4 as String = "This is string4"
     Public String5 as String = "This is string5"
End Sub

Sub Button1_Click
     'If string8.exists Then
          MsgBox(string8, "String Found")
     'Else
          MsgBox("XXX", "String NOT found")
     'End If
End Sub

Thank you in advance
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Never use Msgbox. Only MsgboxAsync.

To answer your question, you cannot use undeclared variables. The compiler will throw an error. It is better to fix this error while you write your code instead of waiting for the program to reach this line.

Use a Map or List to organize your program data.

https://www.b4x.com/etp.html
 
Upvote 0
Top