[單項(xiàng)選擇題] 在窗體中添加兩個(gè)文本框,其名稱(chēng)分別為T(mén)ext1和Text2;兩個(gè)標(biāo)簽,其名稱(chēng)分別為L(zhǎng)abel1和Label2。編寫(xiě)程序,使得程序運(yùn)行后,在文本框
[單項(xiàng)選擇題] 在窗體中添加兩個(gè)文本框,其名稱(chēng)分別為T(mén)ext1和Text2;兩個(gè)標(biāo)簽,其名稱(chēng)分別為L(zhǎng)abel1和Label2。編寫(xiě)程序,使得程序運(yùn)行后,在文本框Text2中輸入小寫(xiě)字母,能轉(zhuǎn)換為比此字母的ASCII碼小4的大寫(xiě)字母,結(jié)果顯示在文本框Text1中。如輸入“efg”,則輸出的結(jié)果為“ABC”,能夠?qū)崿F(xiàn)上述功能的程序是
A.Private Sub Form Load() Show Text1.Text=" " Text2.Text=" " Text2.SetFocusEnd SubPrivate Sub Text2_KeyDown(KeyCode As Integer,Shift As Intege Text1.Text=Chr(KeyCode-4)End Sub
B.Private Sub Form_Load() Show Text1.Text=" " Text2.Text=" " Text2.SetFocusEnd SubPrivate Sub Text2_KeyDown(KeyCode As Integer,Shift As Intege Text1.Text=Text1.Text+Chr(KeyCode-4)End Sub
C.Private Sub Form_Load() Show Text1.Text=" " Text2.Text=" " Text2.SetFocusEnd SubPrivate Sub Text2_Click(KeyCode As Integer,Shift As Intege Text1.Text=Text1.Text+Chr(KeyCOde-4)End Sub
D.Private Sub Form_Load() Show Text1.Text=" " Text2.Text=" " Text2.SetFocusEnd SubPrivate Sub Text2_Click(KeyCode As Integer,Shift As Intege Text1.Text=Chr(KeyCode-4)End Sub
正確答案:B
參考解析:[分析] 當(dāng)在文本框Text2中輸入小寫(xiě)字母時(shí),能觸發(fā)的是KeyDown事件,而不能觸發(fā)Click事件,所以選項(xiàng)C和D是錯(cuò)誤的。選項(xiàng)A的文本框中每次只能顯示一個(gè)字符,而選項(xiàng)B是正確的答案。
詞條內(nèi)容僅供參考,如果您需要解決具體問(wèn)題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。