请问VB怎么实现TextBox控件:键盘不能输入只能通过条码枪输入。
谢谢~!

解决方案 »

  1.   

    不可能,对TEXTBOX来说键盘输入和扫描输入是一回事。
      

  2.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
     KeyAscii = 0
    End Sub
      

  3.   

    楼主既然不想用户输入,那你就用Label来代替TextBox,不就行了?然后将Label的Appearance的属性设为1-3D,BackColor设成白色,BorderStyle设成1-Fixed Single,出来的样子和TextBox的样子一样!
      

  4.   

    晕,忘了没那么复杂,直接设置TextBox的Locked属性为True就OK了。
      

  5.   

    诸位发现没有,VB的 TextBox 的 Locked = True 了,无法输入,但是粘贴仍然有用,这个取决于 msvbvm60.dll 的版本,即使用 sp6 都不一定解决。
      

  6.   

    设置textbox的enabled属性为false不就可以让它不接受输入了吗?
      

  7.   

    楼上的,textbox的enabled属性为false,那文本框都成灰色了,那条码枪还能输入吗?
      

  8.   

    设置textbox的enabled属性为false然后用串口的条码扫描仪不就得了吗?
      

  9.   

    当串口输入事件发生时用text1.text=
      

  10.   

    IcmpSendEcho2 is available in icmp.dll on Windows 2000; it is available in iphlpapi.dll on later versions of Windows. OS version checking is not recommended. Applications requiring portability with this API across Windows 2000, Windows XP, Windows Server 2003 and later Windows versions should not statically link to either icmp.dll or iphlpapi.dll. A Rather, the application should check for the presence of IcmpSendEcho2 in iphlpapi.dll with calls to LoadLibrary and GetProcAddress. Failing that, the application should check for the presence of IcmpSendEcho2 in icmp.dll with calls to LoadLibrary and GetProcAddress.Windows Me/98/95:  Event, ApcRoutine and ApcContext are ignored.
      

  11.   

    估计楼主已经可以解决问题了,罗嗦一句,要注意监视剪贴板的变化或者子类处理textbox控件的WM_PASTE事件
      

  12.   

    干脆用label代替显示算了。
    原来的textbox的visible属性设为false.
    在textbox的change事件中:label.caption=text1.text
      

  13.   

    text1.Locked=True
    text1.text=条码枪得到的数据