[Gambas-user] Re: casting or changing datatype.
Benoit Minisini
gambas at ...1...
Sat Jan 14 17:55:26 CET 2006
On Saturday 14 January 2006 17:46, ron wrote:
> On Saturday 14 January 2006 15:07, Benoit Minisini wrote:
> > But I think what is wanted is the old request of controls indexed by
> > name, like in Visual Basic?
>
> I do not think so, but I have seen you had some code for it in the past
> versions before 1.0 (seen in 0.7x or so).
>
> VB does indexing by number but you can refer to the .Name property
> Iterate the indexed controls by number in a VB control array with
>
> for i = 0 to MyForm.MyAccount.Count -1
> Print MyForm.MyAccount[i].Name & " = " & MyForm.MyAcount[i].Value
> next
>
> will give the same name for all controls in VB.
> Making the array is done by using the same name and increment the index.
> Runtime add of same control to the array does the same name and increment.
>
> For VB the array contains always the same control
> For Gambas the array contains same or different controls, more advanced.
>
> What you asume above is using a name as substitute for the index number.
> Not that bad to have also possible.
>
> The .Name in VB for the group is the .Group you add to gambas.
> There is no need to have the .Name the same as in VB anymore.
>
>
> The old request you mentioned was to be able to use .Name of the control.
> A TextBox on the Form with name 'txtboxUserName' in design and in code the
> 'txtboxUserName_event' can provide 'txtboxUserName.Tag' but not the
> 'txtboxUserName.Name', wich is "txtboxUserName" .
> Simple the .Name property in runtime available for the control.
>
> Using the beatifull Last it could be nice to know the .Name of it to
> determine what to do.
> The VB group is done by .Name+.Index and in Gambas by .Group
> The .Name is used in design and entering the code for reference.
>
>
> Your way of grouping for i.e. account-group properties of different
> controls working on a what_ever event without consider to the control type.
>
> if Last.Index=1 then Last.Value = "MyName"
> if Last.Index=2 then Last.Value = "YourName"
> if Last.Index=3 then Last.Value = 1000
>
>
> Using the .Name property as substitut for .Index you get if
> 'accountGrp' is the .Group name and Last is a control in that group.
>
> Sub accountGrp_event()
> If Last.Name="txtUser" then Last.Value = "MyName" ' or txtUser.Value
> = "MyName" If Last.Name="txtOther" then Last.Value = "YourName"
> If Last.Name="Price" then Last["Price"].Value = 1000 ' or
> Last[Last.Name].Value = 1000 End Sub
You can already do that:
Sub accountGrp_event()
If Last = txtUser then Last.Value = "MyName"
If Last = txtOther then Last.Value = "YourName"
If Last = Price then Last["Price"].Value = 1000
End Sub
Regards,
--
Benoit Minisini
More information about the User
mailing list