Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

請問VB程式如何用Key Press做出這段程式碼?

在螢幕上以文字方塊的控制項輸入資料,只允許英文大小寫,其餘的資料以”0”取代之,並計算英文字個數有幾個。

請幫我就贈送15點知識點數給你 我程式新手 麻煩你€

Update:

請幫我寫程式出來 這素偶滴作業 感恩捏 = ="

2 Answers

Rating
  • DRGO
    Lv 5
    1 decade ago
    Favorite Answer

    s = Text1.Text

    Text1.Text = ""

    n = 0

    For i = 1 To Len(s)

    reg% = Asc(Mid(s, i, 1))

    If (reg >= 65 And reg <= 90) Or (reg >= 97 And reg <= 122) Then

    Text1.Text = Text1.Text & Mid(s, i, 1)

    n = n + 1

    Else

    Text1.Text = Text1.Text & "0"

    End If

    Next

    Me.Caption = "共" & n & "個英文字元"

    2007-05-12 22:06:50 補充:

    沒看清楚題目要求用KeyPress

    Private Sub Text1_KeyPress(KeyAscii As Integer)

    Text1.Locked = True

    Static n As Integer

    Me.Caption = KeyAscii

    If KeyAscii < 65 Or (KeyAscii > 90 And KeyAscii < 97) Or KeyAscii >

    2007-05-12 22:07:58 補充:

    If KeyAscii < 65 Or (KeyAscii > 90 And KeyAscii < 97) Or KeyAscii > 122 Then

    Text1.Text = Text1.Text & 0

    Else

    Text1.Text = Text1.Text & Chr(KeyAscii)

    n = n + 1

    End If

    Me.Caption = "共" & n & "個英文字元"

    End Sub

    連接上面

  • 1 decade ago

    自認新手的請到以下網站看看

    http://vb.ncis.com.tw/

    還有點實力的

    http://www.vbguide.com.tw/webback2.asp

    我是靠這兩個網站學習的

Still have questions? Get your answers by asking now.