CDBL and var error

Hi,

I am very new to Xojo (last time i used Realbasic was back in 2008) so please forgive this simple question…

I get an "This item does not exist " error and a highlight at CDBL and Cstr on the following code:

dim dblHoejde As Double = 0
dim dblVaegt as Double = 0
dblHoejde = cdbl(TextHoejde.Text)
dblVaegt = cdbl (TextVaegt.Text)
dim dblBMI As Double = 0
dblBMI = dblVaegt/(dblHoejde*dblHoejde)

BMIText.Text = Cstr(dblBMI)

I must be doing something very simple wrong … could someone please send me in the right direction?

Thanks in advance!

Kristian Nielsen, Copenhagen, Denmark

Your code worked just fine for me in a desktop project when I pasted it into a button (and after adding the 3 text fields).

What type of project? What platform? Any other info you can provide?

Are you using the new framework? I don’t think CDbl exists there.

Hi,
thanks for your feedback. I guess, i should have given your the full story…

My code origins from Realbasic 2008 where i used it in a desktop app for my Mac. I worked fine then… Now, I wanted to test writing iOS apps and wanted to reuse my code there and got stuck.

So, the errors come when I try to run an iOS app written using Xojo 2015R1.

Hope this can give an explanation.

Kind regards,

Kristian

HI again,

the following worked fine in Xojo 2015R1 on a windows machine (built as a standalone app for Windows)

dim Vaegt As Double dim Hoejde As Double dim BMI As Double Vaegt = cdbl(TextField1.Text) Hoejde=cdbl(TextField2.Text) BMI = Vaegt/(Hoejde*Hoejde) Textfield3.text = Cstr(BMI)

Could it be the fact that i am trying to buld an iOS app ?

regards,

kristian

The “new framework” is what you’re working with in iOS.

[quote=173235:@Kristian Nielsen]HI again,

the following worked fine in Xojo 2015R1 on a windows machine (built as a standalone app for Windows)

dim Vaegt As Double dim Hoejde As Double dim BMI As Double Vaegt = cdbl(TextField1.Text) Hoejde=cdbl(TextField2.Text) BMI = Vaegt/(Hoejde*Hoejde) Textfield3.text = Cstr(BMI)

Could it be the fact that i am trying to buld an iOS app ?
[/quote]

iOS is using a new framework. A lot of the older syntax does not work anymore. You should check http://developer.xojo.com/home which is the language reference for the new framework.

I have created a wrapper that provide some compatibility with older code. It was for my own use originally since I do have older code, just like you, that I needed to port to iOS and did not want to rewrite everything. You could do the same to create a cdbl() method based on double.fromtext() in the new framework.

See https://github.com/Mitchboo/XojoiOSWrapper/tree/master

May I suggest next time you need to post a question about iOS, you do so in the iOS channel. You will get appropraite replies faster.

I just added CDbl to the Wrapper.

For Cstr, you want to have a look at each type, and the ToText method.

BTW, the new framework used by iOS has no String type. It has been replaced by the Text type. Most of the time it can be used the same way, but all your older code using strings will need to be refactored. In particular Dim as String.