Android Question Return Statement

Well I am going to post another question, I don't know how to do that. I looked around and got this:

1. Please post the code AND the error message from the logs as TEXT within CODE TAGS.
I have a how to question, I have no error messages and I have no idea what CODE TAGS are
2. Don't post images
I don't have any images to post
3. Describe what the problem is (full sentences, not 3 words, not "my car doesn't work - guess what it is")
In VB6 in a Function (for that matter a subroutine too) code can be entered like this:
Function SomeFunction(Arg1 as Type1, Arg2 as Type2, ....) as ReturnType
If SomeCondition Then
Return (Answer1)
End if
If SomeOtherCondition Then
Return (Anwer2)
End if
Return (Answer 3)
End Function
note: the function exits on any return statement
I could also write:
Function SomeFunction(Arg1 as Type1, Arg2 as Type2, ....) as ReturnType
If SomeCondition Then
SomeFunction = Answer1
Exit SomeFunction
End if
If SomeOtherCondition Then
SomeFunction = Anwer2
Exit SomeFunction
End if
SomeFunction = Answer 3
End Function
note: the function exits on the Exit or End Statements

So my question is simple:
Can one have multipe return statement in a sub in B4X? as in:
Sub SomeFunction(Arg1 as Type1, Arg2 as Type2, ....) as ReturnType
If SomeCondition Then
Return Answer1
End if
If SomeOtherCondition Then
Return Anwer2
End if
Return Answer 3
Sub End
and will the function terminate when a return is executed?

4. Use the search function FIRST (assume you're not the first person having that question)
i don't know how to use the search function and searching for Return does no result in any practical answers
5. Assume that we have many power users here having huge and complex apps. B4x is working 100%. So if you have an issue it's mostly a programming mistake
i don't know how to code multiple return statements, I don't know what to do (and it is rather arrogant to assume mostly all errors are programming mistakes)
6. Don't start complex projects without any experience
i do not have a complex project (I don't even know what you people consider a complex project)
7. We love to help but you need to help us to understand the issue (see esp. 1 - 3)
i don't think i can be any clearer!!!!
8. Read the tutorials and manuals
i have read the tutorials and manuals they do not answer this simple question
9. Install B4x as described!
i have installed B4X as described. I even installed it on a "clean" computer. Just had Windows 10 on it.
10. Have fun
really?
Erel: 11. Always start a new thread for your question.
I have no idea what this means
I am an expert in VB6 I wrote my first program for money in 1966 (that's correct I am over 70 years old) I ran a very successful software company for over 30 years. At one time my company supported over 300 school districts in the world, and printed over 360,000 report cards a year. The final "think" I did before I sold the company I converted all the VB6 code mechanically to HTML, JavaScript, PHP, and CSS (I wrote that conversion) program. My college degrees are from the University of Wisconsin,.

So I am confused, these 11 steps do not tell me how to ask a question. And I know a lot about systems and programming. My first "school" client purchased my system in 1980.

The steps specify rather obvious steps on how to ask a question, but not one step in where or how i enter a question in the forum.

Happy Computing
Charlie
 

wes58

Active Member
Licensed User
Longtime User
Well I am going to post another question, I don't know how to do that. I looked around and got this:


Happy Computing
Charlie
So you read a thread For new(er) members: How to post a question/issue.
It just tells you what you could/should do when you ask the question.
I have used this forum for a very long time and have never read that thread. I was just asking question.
The way you ask the question depends what the question/problem is. Think, what you would expect to see if someone asked you a question about the problem/issue they have. What information you would need to answer the question.
If you just have just a question do what #3 in that thread was.
If you have a problem/error with your code/application or something doesn't work as you would like to then do what #1 and #3.
What code tags are? When you post a question or reply to a question you can see at the top a toolbar. The first one looks like that "</>". And when you hover a mouse over this you see a text "Code". That's how to use code tags - which makes it easier to view the code.

To answer your question, you do exactly as you did in VB6.
And the answer is using code tags - you can see the difference the way it looks when you compare with you post.

B4X:
Sub SomeFunction(Arg1 as Type1, Arg2 as Type2, ....) as ReturnType
If SomeCondition Then
 Return Answer1
End if
If SomeOtherCondition Then
 Return Anwer2
End if
Return Answer 3
Sub End

Of course you could use "Else If SomeOtherCondition" in the second condition check

#8. Read the tutorials and manuals - or you coulde have tried your code, and you would see if it works or not. That would save you time as well.

You can try a search as in #4, and if you don't find an answer you post the question. There is a chance that someone had the same issue so searching will give you an answer faster. I know it is not easy to find it using the search, but it depends what the problem was.
#11 Always start a new thread for your question. - I could never agree with this one. But this is Erel's forum so you have to (try) to follow the rules.

Just relax.
 
Last edited:
Upvote 0
Top