给点提示 :)
什么都行
谢谢
什么都行
谢谢
解决方案 »
- VB如何操作当前已经打开的工作薄?
- VB如何编写多客户端访问数据库
- 在线等!!! listview 控件两个 如何确保将左边里的内容传入右边里的内容没有重复,通过什么属性?
- 各位JJ、MM、GG、DD:谁知道WebBrowser1.Document的使用方法呀!或介绍个学习的地方
- 各位大哥,为何我用VB6生成dll,在asp里面不能创建组件?
- 高分请教将MSHFlexGrid表中内容导出到EXCEL中的自动化错误问题
- 请问高手,使用microsoft office web componets 9.0做报表,没有预览?急!!!
- 谁有VB关于ADO和SQL SERVER的书?
- 赚积分
- Help me!!Something about ocx and sapi
- 给经验送分(51分)
- 把一个流折分成两段,分别保存为两个文件。100分
使用文本框,
初始化时为“ . . ."
在textChange事件中使text中的内容格式化成上面的格式,(而且还要判断输入的长度来设置光标的位置,以及限制必须输入数字等)
楼主看完 提交 FAQ ,别忘了!
====================================
'''将以下代码 copy 到记事本,保存为 FrmMain 后运行
VERSION 5.00
Begin VB.Form FrmMain
AutoRedraw = -1 'True
BorderStyle = 1 'Fixed Single
Caption = "IP控件演示"
ClientHeight = 3195
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton CmdSet
Caption = "设置结果"
Height = 495
Left = 240
TabIndex = 2
Top = 1500
Width = 885
End
Begin VB.TextBox Text1
Height = 315
Left = 1380
TabIndex = 1
Text = "Text1"
Top = 960
Width = 2595
End
Begin VB.CommandButton CmdGet
Caption = "取得结果"
Height = 435
Left = 210
TabIndex = 0
Top = 870
Width = 885
End
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option ExplicitPrivate Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function INITCOMMONCONTROLSEX Lib "comctl32.dll" Alias "InitCommonControlsEx" (ByRef TLPINITCOMMONCONTROLSEX As INITCOMMONCONTROLSEX) As Long
Private Type INITCOMMONCONTROLSEX
dwSize As Long 'size of this structure
dwICC As Long 'flags indicating which classes to be initialized
End Type
Private Const ICC_INTERNET_CLASSES As Long = &H800Private Const WS_CHILD As Long = &H40000000
Private Const WS_GROUP As Long = &H20000
Private Const WS_TABSTOP As Long = &H10000
Private Const WS_VISIBLE As Long = &H10000000Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Const WM_SETFONT As Long = &H30
Private Const WM_GETFONT As Long = &H31Private Const WM_USER As Long = &H400
Private Const IPM_CLEARADDRESS As Long = (WM_USER + 100)
Private Const IPM_SETADDRESS As Long = (WM_USER + 101)
Private Const IPM_GETADDRESS As Long = (WM_USER + 102)
Private Const IPM_SETRANGE As Long = (WM_USER + 103)
Private Const IPM_SETFOCUS As Long = (WM_USER + 104)
Private Const IPM_ISBLANK As Long = (WM_USER + 105)'#define FIRST_IPADDRESS(x) ((x>>24) & 0xff)
'#define SECOND_IPADDRESS(x) ((x>>16) & 0xff)
'#define THIRD_IPADDRESS(x) ((x>>8) & 0xff)
'#define FOURTH_IPADDRESS(x) (x & 0xff)
'#define MAKEIPRANGE(low, high) ((LPARAM)(WORD)(((BYTE)(high) << 8) + (BYTE)(low)))
'#define MAKEIPADDRESS(b1,b2,b3,b4) ((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4))))
Private IP1 As LongPublic Function FIRST_IPADDRESS(ByVal x As Long) As Byte
FIRST_IPADDRESS = ((x And &H7F000000) \ &H1000000) Or (((x And &H80000000) <> 0) And &H80)
End FunctionPublic Function SECOND_IPADDRESS(ByVal x As Long) As Byte
SECOND_IPADDRESS = (x And &HFF0000) \ &H10000
End FunctionPublic Function THIRD_IPADDRESS(ByVal x As Long) As Byte
THIRD_IPADDRESS = (x And &HFF00&) \ &H100
End FunctionPublic Function FOURTH_IPADDRESS(ByVal x As Long) As Byte
FOURTH_IPADDRESS = x And &HFF
End FunctionPublic Function MAKEIPRANGE(ByVal low As Byte, ByVal high As Byte) As Long
MAKEIPRANGE = high * &H100& Or low
End FunctionPublic Function MAKEIPADDRESS(ByVal b1 As Byte, ByVal b2 As Byte, ByVal b3 As Byte, ByVal b4 As Byte) As Long
MAKEIPADDRESS = ((b1 And &H7F) * &H1000000 Or (b1 And &H80) <> 0 And &H80000000) Or (b2 * &H10000) Or (b3 * &H100&) Or (b4)
End FunctionPrivate Sub CmdGet_Click()
Dim TempLng As Long
SendMessage IP1, IPM_GETADDRESS, 0, TempLng
Text1.Text = FIRST_IPADDRESS(TempLng) & "," & SECOND_IPADDRESS(TempLng) & "," & THIRD_IPADDRESS(TempLng) & "," & FOURTH_IPADDRESS(TempLng)
End SubPrivate Sub CmdSet_Click()
SendMessage IP1, IPM_SETADDRESS, 0, ByVal MAKEIPADDRESS(1, 2, 3, 4)
End SubPrivate Sub Form_Load()
Dim CommCtrl As INITCOMMONCONTROLSEX
CommCtrl.dwSize = Len(CommCtrl)
CommCtrl.dwICC = ICC_INTERNET_CLASSES
If INITCOMMONCONTROLSEX(CommCtrl) Then
IP1 = CreateWindowEx(0, "SysIPAddress32", "IPADDR1", _
WS_CHILD Or WS_TABSTOP Or WS_GROUP Or WS_VISIBLE, _
(Me.ScaleX(Me.ScaleWidth, Me.ScaleMode, vbPixels) - 128) \ 2, 10, 128, 20, _
Me.hwnd, 0, App.hInstance, ByVal 0&)
If IP1 Then
'将IP控件的字体设置的根窗体一样 用宋体
SendMessage IP1, WM_SETFONT, SendMessage(Me.hwnd, WM_GETFONT, 0, ByVal 0&), ByVal 0&
Else
MsgBox "不能创建控件", vbCritical, "错误!"
End
End If
Else
MsgBox "不能创建控件", vbCritical, "错误!"
End
End If
End SubPrivate Sub Form_Unload(Cancel As Integer)
DestroyWindow IP1
End Sub
既然有人有简单的方法,不如拿出来共享一下
你好,我想看看你做的那个控件,
谢了先~~还有源码 呵呵~
谢了!!!