刚给TextBox输入一字符,如何获得这个字符?

6742 2003-11-27 03:37:17
刚给TextBox输入一字符,可能是一个英文字符,也可能是一个汉字,光标可能在最后,也可能不在最后,如何获得这个字符?可不是用眼睛看噢!
...全文
106 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
6742 2003-11-30
  • 打赏
  • 举报
回复
结束!
northwolves 2003-11-28
  • 打赏
  • 举报
回复
Private Sub Command3_Click()
MsgBox LASTINPUT(Text1)
End Sub
Function LASTINPUT(ByVal TXT As TextBox) As String
If TXT.SelStart < 1 Then LASTINPUT = ""
If TXT.SelStart >= 1 Then LASTINPUT = Mid(TXT.Text, TXT.SelStart, 1)
End Function
May2003 2003-11-28
  • 打赏
  • 举报
回复
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim str As String
str = Chr(KeyAscii)
End Sub
dysqw 2003-11-28
  • 打赏
  • 举报
回复
Private Sub Text1_KeyPress(KeyAscii As Integer)
Print Chr(KeyAscii)
End Sub

cbxmir 2003-11-28
  • 打赏
  • 举报
回复
Private Sub Text1_Change()
Dim Str as String
Msgbox Str
End Sub
海牛 2003-11-27
  • 打赏
  • 举报
回复
还是中海的方法简单啊!
海牛 2003-11-27
  • 打赏
  • 举报
回复
Option Explicit
Dim strValue As String

Private Sub Form_Load()
strValue = Text1.Text
End Sub

Private Sub Text1_Change()
Dim I As Long, K As Long, strTmp As String
Dim strT1 As String, strT2 As String, strNewStr As String
Dim lValueLen As Long, lTmp As Long

If Len(strValue) = 0 Then
strValue = Text1.Text
Else
strTmp = Text1.Text
K = Len(strTmp)
lValueLen = Len(strValue)
strNewStr = ""
For I = 1 To K
strT1 = Mid(strTmp, I, 1)
If I - lTmp <= lValueLen Then
strT2 = Mid(strValue, I - lTmp, 1)
If strT1 <> strT2 Then
strNewStr = strNewStr & strT1
lTmp = lTmp + 1
End If
Else
strNewStr = strNewStr & strT1
End If
Next
strValue = strTmp
End If
Me.Caption = strNewStr
End Sub
victorycyz 2003-11-27
  • 打赏
  • 举报
回复
Private Sub Text1_KeyPress(KeyAscii As Integer)
Print Chr(KeyAscii)
End Sub
lemonchen 2003-11-27
  • 打赏
  • 举报
回复
dim str as string
str=textbox

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧