vba 用代码删除控件
介绍 (Introduction)
在回答VB经典区域中 a recent question in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC. I didn't post completely correct code on my first attempt. This is a quick tip about simulating VB classic controls in the VBA code environment. 的最新问题时,我在(Office)VBA环境中编写了一些VB代码,而不是启动我的旧PC。 我第一次尝试时并没有发布完全正确的代码。 这是有关在VBA代码环境中模拟VB经典控件的快速提示。第一次尝试不起作用 (First Attempt Does Not Work)
要回答(文本框按键事件)问题,我需要访问文本框控件的text和selstart属性。 我在属性的模块的“常规声明”部分中添加了几个变量。 我在立即窗口中设置变量,并获得以下代码以返回正确的答案。Option Explicit
Public SelStart As Long
Public Text18 As String
Private Sub Text18_KeyPress(KeyAscii As Integer)
Dim strParsed() As String
Dim strPostKeyValue As String
If SelStart = 0 Then
strPostKeyValue = Chr(KeyAscii) & Text18
Else