不是试用insert吗?要不就自己写这种代码吧。

解决方案 »

  1.   

    大哥那我解释一下:
         edit控件中一般在光标处输入字符那光标就会后移,那我现在是要他在输入字符后,删除光标前的字符,用我输入的字符代替
    如:‘我是’ 现在光标在‘是’之后,我输入‘人’那么就把‘是’
    用‘人’替代,如果是删除‘是’的话,就在原来‘是’的地方变成空格
    明白了吗?
    请指教!
      

  2.   

    在onkeypress中填写以下内容:
    if overwrite then  //overwrite一个插入或改写的变量
    begin 
    edit1.SelLength:=1;
    edit1.SelText:='';
    end;
    不过只能处理字符,不能处理汉字
      

  3.   

    你可以看看COMBOBOX.ONKEYPRESS的帮助示例
      

  4.   

    再key press event里把原来的内容截掉可以嘛?
    是不是太生硬了点
      

  5.   

    有谁懂vb呀
    我有vb的程序
    但我看不懂?
    不能转化为delphi的程序?
    Window环境文字的输入(如textbox)都是Insert Mode而不管实际KeyBoard 的状态是
    Ins/Repl,以下程式可放在TextBox/ComboBox等Control的Keypress Event中,使得
    该Control的文字输入具有OverWrite的功能,而且其最大的文字输入个数不再以Word
    为准,而改以Byte为准,符合中文要求。'以下在form中
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Call KeyPress(KeyAscii)
    End SubPrivate Sub Combo1_KeyPress(KeyAscii As Integer)
    Call KeyPress(KeyAscii, 10)
    End Sub'以下在.bas module中
    Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer'第一个叁数来自KeyPress Event的KeyAscii
    '第二个叁数表示文字最多可输入几个byte,若省略,且文字输入的Control是textbox
    '则最多输textbox中Maxlength的个数(by Byte),若为0表不限定输入字数(by Byte)
    '第三个叁数用在Control项有与DatasSource 做mapping时,其文字输入的最大长度
    '变成table中栏位的最大长度
    '传回传1代表keyascii的值被改过(如:超过字串长),0表一切正常
    Public Function KeyPress(KeyAscii As Integer, Optional Maxlen As Variant,
    Optional dbsource As Control) As Integer
        Dim insmd As Integer, CarStart As Integer
        Dim tmpstr As String
        Dim ctl As Control
         Set ctl = Screen.ActiveControl
        If TypeOf ctl Is TextBox Then
           If ctl.MultiLine Then
              If KeyAscii = vbKeyReturn Then
                 KeyPress = 0
                 Exit Function
              End If
           End If
        End If
        If KeyAscii = vbKeyBack Then
           KeyPress = 0
           Exit Function
        End If
        If IsMissing(Maxlen) Then
           If TypeOf ctl Is TextBox Then
              If dbsource Is Nothing Or Screen.ActiveControl.DataField = "" Then
                 Maxlen = ctl.MaxLength
              Else
                 Maxlen = dbsource.Recordset.Fields(Screen.ActiveControl.DataField).Size
              End If
           Else
              Maxlen = 0
           End If
        End If
        insmd = GetKeyState(vbKeyInsert) And vbShiftMask
        If insmd = 0 Then
           If ctl.SelLength = 0 Then
              CarStart = ctl.SelStart
              tmpstr = Mid(ctl.Text, 1, ctl.SelStart)
              tmpstr = tmpstr + Chr(KeyAscii) + Mid(ctl.Text, ctl.SelStart + 2)
              ctl.Text = tmpstr
              KeyAscii = 0
              If strlen(ctl.Text) > Maxlen And Maxlen <> 0 Then
                 ctl.Text = SubStr(ctl.Text, 1, Maxlen)
                 If strlen(ctl.Text) < Maxlen Then
                    ctl.Text = ctl.Text + " "
                 End If
                 KeyPress = 1
              Else
                 KeyPress = 0
              End If
              ctl.SelStart = CarStart + 1
           Else
              KeyPress = 0
           End If
        Else
          If strlen(ctl.Text + Chr(KeyAscii)) > Maxlen And Maxlen <> 0 Then
             KeyAscii = 0
             KeyPress = 1
          Else
             KeyPress = 0
          End If
        End If
    End Function