Hello World:

1
2
3
4
 

printfn "Hello, World!"

WinForms Hello World:

1
2
3
4
5
6
7
8
9
10
11
 

open System
open System.Windows.Forms

let frm = new Form()
let btn = new Button(Text = "Click me")
btn.Click.Add(fun _ -> MessageBox.Show("Hello, World") |> ignore)
frm.Controls.Add btn
frm.Show()
By on 9/8/2009 11:25 AM ()

Ok, i fixed that problem by adding a referance to it.

How how do i keep the form up instead of it auto closing?

By on 9/8/2009 11:51 AM ()

I think you do Application.Run frm instead of frm.Show(). Just showing will work fine in FSI.

By on 9/8/2009 1:47 PM ()

I stand corrected - I should have stated replace 'frm.Show()' with 'do Application.Run(frm)' if you're using the 'F# Application' template option.

By on 9/8/2009 9:27 PM ()

Hi

I'm also a newbee and also enjoying VS2010 ...

Try the following ..

1> add this line to the code

do Application.Run(frm)

[[link:msdn.microsoft.com]

2> run the program

[By default the F# application in VS2010 is a Console app - if you'd like to get rid of the console screen to the rear of your running form -

1. Right click the project name in the solution explorer and select properties

2. change the output type (on the application tab) from Console to Windows Application.]

BTW Manning Press are offering great deals on their eBooks right now -> check out TomasP's

[link:www.manning.com] - apply for the free chapter and they'll issue you with a discount voucher. Pity O'Reilly don't offer the same deal - but then Chris's eBook is worth paying full priice for.

Greetings from the West of Ireland

By on 9/8/2009 1:47 PM ()

Im using Visual Studio 2010 and i get the error:

namespace Windows is not defined

By on 9/8/2009 11:42 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper