
正文
vb.net数据补位 vba 数字补0
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net 实现ComboBox输入字符自动补充字符
Public Sub AutoComplete(ByVal cmb As ComboBox, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If cmb.DataSource Is Nothing Then
Return
End If
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
Return
End If
Dim strFindStr As String = ""
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Back) Then
If (cmb.SelectionStart = cmb.Text.Length) Then
If cmb.Text.Length 0 Then
strFindStr = cmb.Text.Substring(0, cmb.Text.Length - 1)
End If
Else
If cmb.SelectionStart 0 Then
strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1)
End If
End If
e.Handled = False
Else
If (cmb.SelectionLength = 0) Then
strFindStr = cmb.Text + e.KeyChar
Else
If (cmb.SelectionStart = cmb.Text.Length) Then
strFindStr = e.KeyChar
Else
If cmb.SelectionStart 0 Then
strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1) + e.KeyChar
Else
strFindStr = e.KeyChar
End If
End If
End If
End If
Dim intIdx As Integer = -1
Dim dv As DataView
If TypeOf (cmb.DataSource) Is DataTable Then
dv = CType(cmb.DataSource, DataTable).DefaultView
If strFindStr "" Then
dv.RowFilter = cmb.DisplayMember " Like '%" strFindStr "%'"
Else
dv.RowFilter = ""
End If
cmb.DataSource = dv
cmb.SelectedIndex = -1
cmb.Text = strFindStr
Else
dv = CType(cmb.DataSource, DataView)
If strFindStr "" Then
dv.RowFilter = cmb.DisplayMember " Like '%" strFindStr "%'"
Else
dv.RowFilter = ""
End If
cmb.DataSource = dv
cmb.SelectedIndex = -1
cmb.Text = strFindStr
End If
cmb.SelectionStart = strFindStr.Length
e.Handled = True
End Sub
Private Sub comboBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles comboBox1.KeyPress
AutoComplete(sender, e)
End Sub
相关问答
Q1: 100分 急求在vb.net中怎样进行位操作
用bitarray类和BitVector32类实现
VB实现大致如下:
Imports System.Collections.Specialized
...
Dim bvData as BitVector32
Dim sec1 As BitVector32.Section = BitVector32.CreateSection(255)
Dim sec2 As BitVector32.Section = BitVector32.CreateSection(255,sec1)
Dim sec3 As BitVector32.Section = BitVector32.CreateSection(255,sec2)
Dim sec4 As BitVector32.Section = BitVector32.CreateSection(255,sec3)
Dim Buf(4096) as Byte 'receive byte size matched with DSP send data: 1024*4Byte
Dim recCount as Integer
Dim Data(1024) as long
....
For recCount = 0 To 1023
bvData(sec4) = buf(recByte*4)
bvData(sec3) = buf(recByte*4+1)
bvData(sec2) = buf(recByte*4+2)
bvData(sec1) = buf(recByte*4+3)
Data(recCount) = bvData.Data '这样数据肯定是-398
Next
....
Q2: vb.net 字节数组补0
'写入
Dim bytes() As Byte = {34, 23, 43, 43, 55, 3}
Dim items = (From item In bytes Select item.ToString("000")).ToArray()
System.IO.File.WriteAllLines("c:\test.txt", items)
'读取
Dim items2 = System.IO.File.ReadAllLines("c:\test.txt")
Dim bytes2 = (From item In items2 Select Byte.Parse(item)).ToArray()
For Each item In bytes2
Console.WriteLine(item.ToString())
Next
关于vb.net数据补位和vba 数字补0的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






