[Gambas-user] Return a String from a dialog/form

Marco Bauer elentirmo at ...20...
Tue Jul 19 21:22:41 CEST 2005


Am Dienstag, 19. Juli 2005 20:36 schrieb Benoit Minisini:
> On Tuesday 19 July 2005 14:54, Marco Bauer wrote:
> > Hi everyone,
> >
> > I tried to build a form which should return a string value to the main
> > form when closed. I know this works with boolean values but with string
> > values I get the runtime error "Type mismatched: wanted Integer, got
> > String instead".
> >
> > Did I completly mess up or what did I wrong? Can please somebody help me
> > (you find attached the corresponding class-file and the call from the
> > main form).
> >
> > Thanks.
> > Marco
> >
> >
> > ' Main file
> > ...
> >   sNeuePosition = FInputPosition.Run(sPosition)
> > ...
> >
> > ' Gambas class file
> > PUBLIC SUB _new(sPosition AS String)
> >   DIM sArray AS String[]
> >
> >   sArray = Split(sPosition, " ")
> >
> >   txtPosition.Text = sArray[0]
> >   spnAmZug.Value = CInt(sArray[1])
> > END
> >
> > STATIC PUBLIC FUNCTION Run(sPosition AS String) AS String
> >   DIM hForm AS Form
> >
> >   hForm = NEW FInputPosition(sPosition)
> >   RETURN hForm.ShowModal()
> > END
> >
> > PUBLIC SUB btnCancel_Click()
> >   ME.Close(" ")
> > END
> >
> > PUBLIC SUB btnOk_Click()
> >   IF PositionErlaubt() = TRUE THEN
> >     ME.Close(txtPosition.Text & " " & CStr(spnAmZug.Value))
> >   ELSE
> >     Message.Error("This is not a legal position! Please try again!")
> >   END IF
> > END
> >
> > PRIVATE FUNCTION PositionErlaubt() AS Boolean
> >   RETURN TRUE
> > END
>
> Me.Close() argument is an integer, not a string!
>
> If you want to return something more complex than an integer in a form, put
> them in static public variables. Look in the IDE or database manager source
> codes. You will find many dialog boxes, and I did this way :-)
>
> Regards,

Thanks Benoit,

could've thought of this myself. :-) I will give the gambas source a try.

Regards,
Marco




More information about the User mailing list