# FreeBASIC/Getting Started

 目錄 FreeBASIC 上一课 Getting Started 下一课

## 变量

### 用变量存储数据

```Dim text As String
text = "Hello World!"
Print text
Sleep
```

`Hello World!`

• Single 单精度符点型
• Double 双精度符点型
• Integer 整数型

### 在表达式中使用变量

```Dim a As String, b As String, text As String
a = "Hello"
b = "World"
text = a + " " + b + "!"
Print text
Sleep
```

`Hello World!`

## 数据输入输出

### 通过用户输入得到数据

```Dim answer As String
Input "Type something and press enter: ", answer
Print "You typed: '"; answer; "'"
Sleep
```

`Wikibooks.`

`You typed: 'Wikibooks.'`

### 做些数学题

```Dim a As Integer, b As Integer, c As Integer
a = 1
b = 2
c = a + b
Print c
Sleep
```

`3`

### 用 Input 语句做些数学题

```Dim a As Integer, b As Integer, c As Integer
Input "a = ", a
Input "b = ", b
c = a + b
Print "c = a + b ="; c
Sleep
```

```1
2```

`c = a + b = 3`

### 用 Input 语句做更多的数学题

Input 语句也可以用于解决实际问题，如单位换算。

```Dim As Single lb, kg
Input "Enter a weight in pounds:", lb

kg = lb * 0.454
Print lb; " lb. is equal to "; kg; " kg"
```

`2`

`2 lb. is equal to 0.908 kg`