VBA輸入框(InputBox) 六

2022-06-01 19:00:08 字數 1198 閱讀 3601

inputbox函式提示使用者輸入值。當輸入值後,如果使用者單擊確定 按鈕或按下鍵盤上的enter 鍵,inputbox函式將返回文字框中的文字。如果使用者單擊「取消」 按鈕,該函式將返回乙個空字串("")。

語法

inputbox(prompt[,title][,default][,xpos][,ypos][,helpfile,context])
引數說明在這個示例中,通過在兩個輸入框(乙個用於長度,乙個用於寬度)的幫助下在執行時從使用者獲取值來計算矩形的面積。實現**如下 -

function

countarea()

dim length as

double

dim width as

double

length = inputbox("

輸入乙個長度值:

", "

輸入長度")

width = inputbox("

輸入乙個寬度值:

", "

輸入寬度")

findarea = length *width

countarea =findarea

實現過程 -

第1步- 執行相同的操作,使用函式名稱進行呼叫,然後按enter鍵,如下圖所示。

第2步- 執行時(點選單元格,然後移出時即觸發執行),顯示第乙個輸入框(長度),在輸入框中輸入乙個值。

彈出乙個輸入框,並輸入長度值

第3步- 輸入第乙個值後,顯示第二個輸入框(寬度)。

第4步- 輸入第二個數字後,單擊確定 按鈕。該區域顯示計算得到結果如下面的截圖所示。

VBA 學習筆記 輸入框

學習資料 提示使用者輸入值。當輸入值後,如果使用者單擊確定 按鈕或按下鍵盤上的enter 鍵,inputbox函式將返回文字框中的文字。如果使用者單擊 取消 按鈕,該函式將返回乙個空字串 inputbox prompt title default xpos ypos helpfile,context...

輸入框輸入限制

public class verifytext 主監聽 regexpverifylistener regexpverifylistener null regexpverifylistener regexpverifylistener this.text.getdata digitverifylist...

輸入框輸入金額

用法 第一種 inputfilter filters edshopprice.setfilters filters edmarketprice.setfilters filters 第二種 edshopprice.setfilters new inputfilter edmarketprice.se...