The script has several problems, Textbox3 got lost some where and there's problems with indentation (probably caused by the copy paste). The error your seeing is caused by the last bit where the "let run()=" is unnecessary:

1
2
3
[<STAThread><STATHREAD>]
let run()=
do Application.Run(form)

Also note "E" should be a function. Full code should be:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#light


open System

open System.Windows.Forms

let form = new Form(Visible=true, TopMost=true, Text="", Width=500, Height=300, FormBorderStyle=FormBorderStyle.Fixed3D)

let combobox1 =
    let COMBOBOX = new ComboBox()
    COMBOBOX.Width <- 35
    COMBOBOX.Top <- 10
    COMBOBOX.Left <- 10
    COMBOBOX.Items.Add("a") |> ignore
    COMBOBOX.Items.Add("b") |> ignore
    COMBOBOX.Items.Add("c") |> ignore
    COMBOBOX

let mapValue() =
    match combobox1.SelectedItem :?> string with
    | "a" -> 1
    | "b" -> 2
    | "c" -> 3
    | _ -> 0

let Textbox3 = new TextBox(Top=50)

let btn1 =
    let BUTTON = new Button(Top=100)
    BUTTON.Text <- sprintf "="
    BUTTON.Left <- 50
    BUTTON.Top <- 10
    BUTTON.Width <- 30
    BUTTON.Click.Add( fun _ ->
        Textbox3.Text <- sprintf "%d" (mapValue()))
    BUTTON

do form.Controls.Add(combobox1)

do form.Controls.Add(btn1)
do form.Controls.Add(Textbox3)

[<STAThread>]
do Application.Run(form)
By on 11/19/2008 12:58 AM ()

Thanks! :)

By on 11/19/2008 7:04 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