重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
对位模式执行数学左移位。
创新互联建站是少有的成都网站制作、成都网站设计、外贸营销网站建设、营销型企业网站、微信小程序定制开发、手机APP,开发、制作、设计、友情链接、推广优化一站式服务网络公司,于2013年开始,坚持透明化,价格低,无套路经营理念。让网页惊喜每一位访客多年来深受用户好评
result = pattern amount
各部分说明
result
必选。整型数值。对该位模式进行移位的结果。数据类型与 pattern 的数据类型相同。
pattern
必选。整型数值表达式。要进行移位的位模式。数据类型必须为整型(SByte、Byte、Short、UShort、Integer、UInteger、Long 或 ULong)。
amount
必选。数值表达式。要将该位模式移位的位数。数据类型必须为 Integer 或扩展到 Integer。
备注
数学移位不是循环的,即不会将在结果的一端移出的数位从另一端重新移入。在数学左移位运算中,丢弃移出结果数据类型范围的数位,而将右端空出的数位位置设置为零。
为防止移位的结果超出它所支持的位数,Visual Basic 使用与 pattern 的数据类型相对应的大小掩码来屏蔽 amount 的值。可使用这些值的二进制与运算结果作为移位量。大小掩码如下所示:
pattern数据类型 掩码(十进制)掩码(十六进制)
SByte, Byte 7 H00000007
Short, UShort 15 H0000000F
Integer, UInteger 31 H0000001F
Long, ULong 63 H0000003F
如果 amount 为零,则 result 的值与 pattern 的值相同。如果 amount 为负值,则将把它作为无符号的值,并使用相应的大小掩码进行屏蔽。
数学移位绝不会产生溢出异常。
例如:TextBox控件,只要在属性窗口将 PasswordChar 设置为你想要显示的符号即可。如“*”、“?”等
假如Form1有个TextBox1,双击TextBox1填入123
Public Class Form1
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick
System.Windows.Forms.SendKeys.Send("123")
End Sub
End Class
看你的VB.NET 版本了
用 My.Computer.Keyboard.SendKeys("123", True) 代替 System.Windows.Forms.SendKeys.Send("123") 也可以
原码:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick
My.Computer.Keyboard.SendKeys("123", True)
End Sub
End Class
用正则表达式可以实现:
Regex.IsMatch(this.textBox1.Text, @"^([1-9]|[1-9]\d|1\d{2}|2[0-1]\d|22[0-3])(\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])){3}$")
返回是bool型的,调试通过了,可以加入到IF语句判断,楼主可以试试.
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If Asc(0) Then
textbox1.text="0"
end if
end sub
写dns的时候,老是提示失败,但能成功写入...
Private Sub Command1_Click()
MsgBox ChangeIP("10.81.203.58", "255.255.255.0", "10.81.203.21", "202.102.128.68", "202.102.134.68")
End Sub
Function ChangeIP(IP As String, NM As String, GW As String, MDNS As String, SDNS As String) As String
'返回值说明:返回一个设置的中文说明.
Dim strComputer, objWMIService, colNetAdapters, strIPAddress, strSubnetMask
Dim strGateway, strGatewaymetric, strDNS, objNetAdapter, errEnable, errGateways, errDNS
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" strComputer "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array(IP) 'ip地址
strSubnetMask = Array(NM) '子网掩码
strGateway = Array(GW) '网关
'MsgBox TypeName(strGateway)
strDNS = Array(MDNS, SDNS) '主DNS各备DNS
strGatewaymetric = Array(1)
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
errDNS = objNetAdapter.SetDNSServerSearchOrder(strDNS) 'DNS为空的话,改为errDNS = objNetAdapter.SetDNSServerSearchOrder()
If errEnable = 0 And errGateways = 0 And errDNS = 0 Then
ChangeIP = "设置成功"
Else
If errEnable = 0 Then
ChangeIP = "IP地址和子网掩码设置成功, "
Else
ChangeIP = "IP地址或子网掩码设置失败, "
End If
If errGateways = 0 Then
ChangeIP = ChangeIP "默认网关设置成功, "
Else
ChangeIP = ChangeIP "默认网关设置失败, "
End If
If errDNS = 0 Then
ChangeIP = ChangeIP "DNS设置成功"
Else
ChangeIP = ChangeIP "DNS设置失败"
End If
End If
Next
End Function