On Thu, Aug 9, 2012 at 11:23 AM, rocko <sunblast...@gmail.com> wrote: > Trying to get a message.info to display when a successful connection > to a database is made. > Tried using an 'Else If' after a 'Try $hConn.Open' statement > but that gives an error. > So tried a simple 'If' but I'm not sure how the syntax should be. > > CODE: > Try $hConn.Open > If Error Then Print "Database cannot be opened. Error = ", Error.Text > > If $hConn.Open Then > Message.Info("You are now connected to the database.") > Endif >
OK Rokko, >From the IF help page... If <expression> Then ... else ... End If <expression> must be some "construct" that RETURNS a value that can be interpreted as being True or False. Where "construct" is a boolean value(1) or a function that returns a boolean(2) or a statement that evaluates as a boolean(3) and some others. 1) Dim myValue as Boolean=True 2) Function MyValue() as Boolean 3) ThisString=ThatString Connection.Open from the help page at http://gambasdoc.org/help/comp/gb.db/connection/open?v3 is a SUB. It doesn't return anything. Do you now see what's wrong with your code? See also http://gambasdoc.org/help/cat/methoddecl?v3 The gambas help pages explain everything, but they are very very succinct. Above my desk is a large sign that says "READ EVERY WORD OF THE GAMBAS HELP PAGE!", to which I have to constantly refer. hth Bruce ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user