Basic Input
 
获取信息到您的计划。

输入是任何程序的生命。如果你不能得到一些东西进入你的程序,你将如何得到任何东西呢?您将在这里找到的是如何获取信息到您的FreeBASIC程序的基础知识。

这是一个非常基本的程序,将要求你的名字:

'Create a place to put the user's name
Dim As String strMyName

' Ask for the user's name and store it in the string 'strMyName'
Input "What is your name? ", strMyName

' Wait half a second
Sleep 500

' Show them their name
Print
Print "I now know your name is "; strMyName
Print

' Wait until someone presses a button before you exit
Print "Press any button to exit"
Sleep


INPUT是从某人获取信息的最简单的方法。他们只是输入一些文字,按完成后按Enter键。

如果你只想要一个击键怎么办?最简单的方法是使用GetKey方法。GetKey给出您按下的键的ASCII值。

' Ask the user for input
Print "Press your favorite key:"

' Set a place to keep the ASCII value of the key
Dim As Integer strKeyPress

' Keep going until a key is pressed
Do
    strKeyPress = GetKey    
Loop Until strKeyPress <> 0    

' Show the key the user pressed
Print
Print "Your favorite key is: "; Chr(strKeyPress)                        
                        
' Wait until someone presses a button before you exit
Print
Print "Press any button to exit"
Sleep


有关更多信息,请查看用户输入en部分。