Professional Documents
Culture Documents
If you don't need all the "special" functonality of the data grid (namely the
bold lines between each cell and the ability to know which cell you are editing)
then use a listview in detail mode with gridlines on.
Dim CN as ADODB.Connection
DIM RS as ADODB.RecordSet
Dim NewItem as ListItem
RS.MoveNext
Loop
RS.Close
CN.Close
--------------
This sample was added after a superb response from the CodeGuru VB discussion
forum. The original requirement was for a way of entering and modifying a list of
data in a tabular format. Lothar suggested the use of a disconnected ADOR
recordset and the DataGrid control that comes with VB6 - a simple solution that
works perfectly for the job.
Firstly, you need to set a reference to Microsoft Active Data Objects Recordset
2.1 library (msador15.dll). Then add the DataGrid component into your VB6 toolbar
and paste in the following code into the Form_Load event after adding a Grid
(DataGrid1) to your form:
'
' Create a new disconnected recordset object
'
set r = new ADOR.Recordset
'
' Setup the fields - you can use any valid type of
' ado field type for these. I've used VarChar just
' for testing / demonstration purposes.
'
r.Fields.Append "Name", adVarChar, 10
r.Fields.Append "Notes", adVarChar, 50
r.CursorType = adOpenDynamic
r.Open
r.AddNew
r.Fields(0).Value = "Chris"
r.Fields(1).Value = "almost over the hill"
r.AddNew
r.Fields(0).Value = "Chris"
r.Fields(1).Value = "but enjoying every minute"
for lCount = 1 to 25
r.AddNew
r.Fields(0).Value = "Name " & lCount + 2
r.Fields(1).Value = "some kind of description"
next
'
' Populate the datagrid
'
set DataGrid1.DataSource = r
End Sub
------------
First go to access and creat a database for example database name is "Test". Then
creat a table having some name for example "Invoice_info", having some field
according to ur requirment.
Then come on to VB6 and select VB Enterprise Control Application form place as
many textboxes as u've fields in ur table.
For example ur table has 4 fields
invoice(string)
Name(String)
Date(dateandtime type)
Amount(Number)
Create 4 textboxes for each field. And 2 command buttons 1 for save the record and
1 for retreive the record.
Then past Adodc on ur VB Form. and palces these lines of code
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
App.Path & "\Test.mdb;Persist Security Info=False"
End Sub
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "Invoice_info"
Adodc1.Refresh
Text1.Text = Adodc1.Recordset.Fields(0)
Text2.Text = Adodc1.Recordset.Fields(1)
Text3.Text = Adodc1.Recordset.Fields(2)
Text4.Text = Adodc1.Recordset.Fields(3)
End Sub
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields(0) = Text1.Text
Adodc1.Recordset.Fields(1) = Text2.Text
Adodc1.Recordset.Fields(2) = Text3.Text
Adodc1.Recordset.Fields(3) = Val(Text4.Text)
Adodc1.Recordset.Update
Unload Form1
Load Form1
Form1.Show
End Sub
Note that the database must be at the location where the VB application is. Means
the VB application and Access Data base must be in same folder.
----------------
Allow Multiple Winsock Connections to One Server
The Winsock control allows you to make only one connection between two computers.
However, you can create multiple connections (many computers to one) by creating
multiple instances of the Winsock control at run time.
Add a Winsock control to your form and set its index to 0, then add this code into
the server machine to allow multiple connections to it:
Option Explicit
Public NumSockets As Integer
'//Public Variable to track number of Connections
You should now be able to continue to accept connections from multiple sources.
Stuart Snaith
-----------
Introduction
This is the best free grid control for VB 6. With this control you can format each
field (set font name, bold, italic, underline, align), it's very easy to use.
Support AddRow and AddColumn. Also have can auto add new row if you accessed to
last row. Events (click, change...) gives you indexes of last and new column/row.
There is much properties, so you can easly create design at your wishes (fore
color, fore color selected, grid coloe, grid color fixed, back color, back color
selected, back color fixed...).
There is also property RowFixedData where you can choose what will be printed in
rowname field (it's first column). You can choose between UserDefined � show text
defined by programmer, RowNumber � auto generate row numbers and show them,
SelectedPointer � Show * at selected row.
Example codes
Me.ucGrid1.Cols = 5
Me.ucGrid1.Rows = 1
' Set row / column names � if first index is 0 then you change column names, if
second index is 0 then you change row names:
Me.ucGrid1.Data(0, 1) = "ID"
Me.ucGrid1.Data(0, 2) = "Name"
Me.ucGrid1.Data(0, 3) = "Phone"
How to use
This is Standard EXE project. If you wont to add this to your project you must
copy all modules and user control to your project dirertory. After that youst add
this files to your project.
If you want, you can create ActiveX project and add this file to this project and
create OCX.
Properties:
- AutoAddNextRow As Boolean � if True then control will automatic add new row when
you acces to last row.
- Cols As Long � number of columns, when changed all data are delited
- Rows As Long � number of rows, when changed all data are delited
- FldFontBold(ByVal mRow As Long, ByVal mCol As Long) As Boolean � field font bold
- FldFontName(ByVal mRow As Long, ByVal mCol As Long) As String � filed font name
Screenshot - screenshot.jpg
Introduction
Recently, a customer asked if it would be possible to add some specific
functionality to a program written by us. The program in question displayed the
forces and streamed in real-time, acting on the various axles of a racing car. The
version at the time simply had a PictureBox control in VB6 with text boxes, etc.
positioned around the picture to display the values. The customer was requesting
that this whole "picture" be scaled depending on the size of the window, so that
on large screens it would be easier to read.
The problem
Put quite simply, the language in which the application was written, VB6, does not
provide very good support for graphics. This is especially the case for resizing
pictures proportionally, which was the one major client requirement.
The solution
The timeframe for implementing the solution was limited, so although not
completely out of the question, a complete re-write of the software in VB.NET was
not really feasible. One possibility which presented itself was to see if a
control written using .NET could be used in a VB6 application using COM Interop.
As it turned out, this is quite easy, but the leg-work involved behind it revealed
quite a few dead-ends. So, it is the aim of this article to eliminate those dead-
ends for other people wishing to accomplish the same thing.
Stage 1: creating the control
This took the longest of the three stages in our case, simply because of the
nature of the control and calculating the positions of where text, etc. was meant
to be positioned. I will not delve into the details of our control, but only the
steps that are required for VB6 Interop.
1.
Create a new Windows Control Library project from within Visual Studio.
Screenshot - stage1step1.gif
2.
In both the Debug and Release modes of the Property Pages, set the "Register
for COM Interop" checkbox.
Screenshot - stage1step2.gif
3. Inside the AssemblyInfo.cs file, change the assembly wide attribute
ComVisible to true. If it's not already in the configuration file, add it.
[assembly: ComVisible(true)]
That is all that is required to make the project visible to VB6 projects.
Properties
A quick word about these: properties are exposed to VB6 so, like .NET controls, if
you want to expose a value you must wrap it in a Property expression. You cannot
just have it visible as a field.
Stage 2: registering the assembly
The library must be registered on the client machine before use by VB6. If it is
not registered on the development machine, then it will not be visible in the
References dialog of VB6. If it's not registered on the installation machine, then
it is a similar problem to if you have not registered a classic DLL or ActiveX
control. The "Register for COM Interop" checkbox in VS2005 performs this
registration automatically while the environment is running, but un-registers it
when VS is closed.
To register the assembly, you must use the .NET equivalent of regsvr32, regasm.
This is located in the framework directory, usually
"C:\WINDOWS\Microsoft.NET\Frmaework\v2.0.50727". To register it, open a command
prompt and run the following command, assuming that the framework directory and
the assemblies directory are in the environment's current path.
regasm.exe Assembly.dll
The secret here is the VBControlExtender object, which allows a .NET control to be
hosted on a VB6 form. However, the first stage is to add a reference to the
assembly you just registered. This is accomplished by checking the box in the
Project | References menu.
Screenshot - references.gif
Once that has been accomplished, then the following code can be added to the
form's code in the project:
Option Explicit
Dim car As VBControlExtender
The other code included in the demo's source file simply resizes the control based
on the form size and sets random values to the properties of the control.
You'll notice that I have had to refer to the properties of the .NET control
through car.object. This provides late-binding functionality for VB6. All COM-
Visible methods in the .NET control are accessible through this object. You just
have to know what you're typing because it is late-bound.
Summary
Hopefully my ability (or lack thereof) as an article writer hasn't masked the
important bits of the article so much that it is unusable. I personally find that
the code speaks for itself and have included all .NET & VB6 code in the attached
ZIP files, so do take a moment to browse through them.
History
About Ed.Poore
Ed is a student who due to a form of cancer (now clear) took a year out
before going to Imperial College, London to study Electronics Engineering.
He lives on a 57 acre farm in West Wales, Great Britain with the rest of his
family.
<%
Set demoConn = Server.CreateObject("ADODB.Connection")
demoFilePath = Server.MapPath("yourdatabase.mdb")
demoConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & demoFilePath &
";"
%>
<%
Set demoConn = Server.CreateObject("ADODB.Connection")
'this is the line to change
demoFilePath = "E:\database\yourdatabase.mdb"
demoConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & demoFilePath &
";"
%>
dstart = Timer
Adodc1.Refresh
Adodc2.Refresh
On Error Resume Next
ProgressBar1.Visible = True
pnlstatus.Text = "Transfering data please wait...."
StatusBar1.Refresh
ProgressBar1.Max = Val(Text1.Text)
For icounter = 1 To Val(Text1.Text)
If icounter Mod 10 = 0 Then ProgressBar1.Value = icounter
Next icounter
dstart = Timer
Adodc1.Refresh
Adodc2.Refresh
On Error Resume Next
ProgressBar1.Visible = True
pnlstatus.Text = "Returning data please wait...."
StatusBar1.Refresh
ProgressBar1.Max = Val(Text1.Text)
For icounter = 1 To Val(Text1.Text)
If icounter Mod 10 = 0 Then ProgressBar1.Value = icounter
Next icounter
Khi m� em th�m m?i m?t b?n ghi th� datagrid s? kh�ng hi?n th? lu�n d�ng du?c th�m
m?i. Ch?ng h?n em th�m d�ng 1, th� d�ng 1 kh�ng du?c hi?n th? l�n ngay. Khi em
th�m d�ng th? 2 th� n� m?i hi?n th? d�ng 1. Em ph?i gi?i quy?t nhu th? n�o d�y.
B�c n�o bii?t th� gi�p em v?i??? :oops:
45
lbkduy
Th�nh vi�n m?i
Th�nh vi�n m?i
B�i vi?t: 2
Ng�y tham gia: Th? 6 27/04/2007 10:35 pm
�?n t?: 45
�?u trang
tien_nt
Th�nh vi�n m?i
Th�nh vi�n m?i
B�i vi?t: 2
Ng�y tham gia: Th? 3 24/04/2007 11:36 pm
�?n t?: HaNoi
�?u trang
Re: Datadrid v?i ADO
lbkduy d� vi?t:Em ch�o c�c b�c. C�c b�c gi�p em v?i. Em d�ng ADODC d? k?t n?i
CSDL. Gi? s? 1 Form c?p nh?t Th�ng tin kh�ch h�ng c?a em c� c�c th�ng tin: M�
kh�ch h�ng, T�n kh�ch h�ng.... v� m?t datagrid d? hi?n th? danh s�ch kh�ch h�ng.
Khi load datagrid em c� m?t th? t?c
private sub loaddatagrid()
dim Sql as string
sql="SELECT * FROM tblKhachHang"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
App.Path & " \Data\QLKhachHang.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = sql
set datagrid1.Datasource=adodc1
end sub
Khi m� em th�m m?i m?t b?n ghi th� datagrid s? kh�ng hi?n th? lu�n d�ng du?c
th�m m?i. Ch?ng h?n em th�m d�ng 1, th� d�ng 1 kh�ng du?c hi?n th? l�n ngay. Khi
em th�m d�ng th? 2 th� n� m?i hi?n th? d�ng 1. Em ph?i gi?i quy?t nhu th? n�o d�y.
B�c n�o bii?t th� gi�p em v?i??? :oops:
hoangnn
Th�nh vi�n t�ch c?c
Th�nh vi�n t�ch c?c
B�i vi?t: 68
Ng�y tham gia: Th? 3 28/02/2006 9:19 am
�?n t?: ��t Qu?ng
* G?i Email
* T�i kho?n Yahoo
�?u trang
G?i b�ig?i b?i lbkduy v�o ng�y Ch? nh?t 29/04/2007 6:31 pm
C�m on c�c b�c nhung em d� l�m nhu v?y m� v?n kh�ng du?c
adodc1.refresh
datagrid1.refresh
45
lbkduy
Th�nh vi�n m?i
Th�nh vi�n m?i
B�i vi?t: 2
Ng�y tham gia: Th? 6 27/04/2007 10:35 pm
�?n t?: 45
�?u trang
List1.Clear
Do Until Adodc1.Recordset.EOF
List1.AddItem (Adodc1.Recordset.Fields(1))
Adodc1.Recordset.MoveNext
Loop
If Adodc1.Recordset.EOF And Adodc1.Recordset.RecordCount > 1 Then
MsgBox "Records Found"
End If
End Sub
---------------
Task: You can connect to a remote computer(remote pc must be running the server
application) then u can execute any file and send any keystroke on the remote pc.
next version will be released sonn
'Client
'add 3 text box, 2 button, 1 winsock control name the control to sckClient
Private Sub Command1_Click()
sckClient.RemoteHost = Text1.Text
sckClient.RemotePort = 12345
sckClient.Connect
End Sub
End Sub
End Sub
**********************************************
'server
'for server u need only 1 winsock control name the control sckServer
End Sub
End Sub
sckServer.GetData strData
fs = Left(strData, 1)
If fs = "E" Then
Shell Right(strData, Len(strData) - 1), vbMaximizedFocus
End If
SendKeys strData
End Sub
----------------
Task: Retrieve a remote MAC Address
Option Explicit
Text1.Text = "192.168.1.101"
Text2.Text = ""
Command1.Caption = "Get Remote Mac Address"
End Sub
End If
End Sub
'set PhyAddrLen to 6
PhyAddrLen = 6
If bpMacAddr(cnt) = 0 Then
tmp = tmp & "00-"
Else
tmp = tmp & Hex$(bpMacAddr(cnt)) & "-"
End If
Next
Exit Function
Else
GetRemoteMACAddress = False
End If
Else
GetRemoteMACAddress = False
End If 'SendARP
Else
GetRemoteMACAddress = False
End If 'dwRemoteIP
End Function
-------------------
Task: Connect to a database using VB6
Dim Conn As Connection
' public variables for the server, database, user name and password
Public mServer as String
Public mDb As String
Public mUsr As String
Public mPwd As String
'The class is as under:
End Function
' takes the query as a string and returns the opened recordset
Public Function GetRecordset (ByVal strQuery As String, rstResult As Recordset) As
Boolean
Dim rst As New Recordset
Conn.CommandTimeout = 60
rst.Open strQuery, Conn, adOpenDynamic
If rst.RecordCount <= 0 Then
GetRecordset = False
Else
Set rstResult = rst
GetRecordset = True
End If
End Function
' takes the query as a string and returns the forward only recordset using Command
Object
Public Sub GetInfo(strQuery As String, ByRef rst As ADODB.Recordset)
' takes a update or delete query as string and updates the database
Public Sub UpdateIt(ByVal strQuery As String)
End Function
-----------------
Task: Get your REAL REMOTE IP address in the EASIEST WAY! All this snippet Relies
on is the Inet component! Dont waste your time, with 100's of lines of CODE to get
your Remote IP! Use my CODE and only use 4 LINES OF CODE!!!
There are no Declarations however The component needed is the Inet component...
Which is found in your vB Component addition tab... Locate the Microsoft Internet
Transfer Protocol. (This is the Inet controller) hence this remarking is for the
beginners.
1 form
1 TextBox
1 Inet control .....and the following 'simple' code snippet.
'note I usually put this in the form load, but it's universal - you can add it to
a button, and have it destinate in any textbox field of your choice.
Dim MyIP As String
MyIP = Inet1.OpenURL("http://pchelplive.com/ip.php")
text1.Text = MyIP
text1.Text = Replace(text1, Chr(10), "")
-------------
Task: How to ping an IP address using VB.
'1) Place a command button on the form and place this code in the Click event
Dim ECHO As ICMP_ECHO_REPLY
Dim pos As Integer
Form1.Print ECHO.DataPointer
'2) Add a .BAS module and paste this code in that module
'3) Click the command button
Option Explicit
GetStatusCode = CStr(status) & " [ " & msg & " ]"
End Function
End Function
Public Function LoByte(ByVal wParam As Integer)
End Function
Call SocketsInitialize
hPort = IcmpCreateFile()
If IcmpSendEcho(hPort, _
dwAddress, _
sDataToSend, _
Len(sDataToSend), _
0, _
ECHO, _
Len(ECHO), _
PING_TIMEOUT) Then
Call IcmpCloseHandle(hPort)
Call SocketsCleanup
End Function
Dim i As Integer
Dim parts(1 To 4) As String
i = 0
i = i + 1
parts(i) = tmp
If i <> 4 Then
AddressStringToLong = 0
Exit Function
End If
End Function
Dim X As Long
X = WSACleanup()
If X <> 0 Then
MsgBox "Windows Sockets error " & Trim$(Str$(X)) & _
" occurred in Cleanup.", vbExclamation
SocketsCleanup = False
Else
SocketsCleanup = True
End If
End Function
X = WSAStartup(WS_VERSION_REQD, WSAD)
If X <> 0 Then
MsgBox "Windows Sockets for 32 bit Windows " & _
"environments is not successfully responding."
SocketsInitialize = False
Exit Function
End If
End If
SocketsInitialize = True
End Function
---------
Task: This is the code which u can not get from books easily. This code provides u
understanding of Flex Grid Control and How to use it.
Option Explicit
Dim Mode As String 'Stores the current operation "add" or "edit"
Dim CON As Connection 'A Connection variable
Dim RS As Recordset 'A RecordSet variable
Private Sub CmdAddIns_Click()
On Error GoTo ErrHandler
Mode = "add"
MSFlexGrid1.Clear 'Clearing the data in the FlexGrid
MSFlexGrid1.FormatString = "ID |Name "
MSFlexGrid1.Rows = 2 'One FixedRow + One Empty Row
MSFlexGrid1.SetFocus
Exit Sub
ErrHandler:
MsgBox "An Error has Occured In The FlexChk() Procedure" & vbCr & "Report This
Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr & "Error Number
: " & Err.Number & vbCr & "Error Description : " & Err.Description, vbCritical,
"FlexGrid Example"
End Sub
ErrHandler:
MsgBox "An Error has Occured In The CmdSaveUpdate_Click() Procedure" & vbCr &
"Report This Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr &
"Error Number : " & Err.Number & vbCr & "Error Description : " & Err.Description,
vbCritical, "FlexGrid Example"
End Sub
ErrHandler:
MsgBox "An Error has Occured In The CmdEditMod_Click() Procedure" & vbCr &
"Report This Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr &
"Error Number : " & Err.Number & vbCr & "Error Description : " & Err.Description,
vbCritical, "FlexGrid Example"
End Sub
ErrHandler:
MsgBox "An Error has Occured In The MSFlexgrid1_KeyPress() Procedure" & vbCr &
"Report This Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr &
"Error Number : " & Err.Number & vbCr & "Error Description : " & Err.Description,
vbCritical, "FlexGrid Example"
End Sub
ErrHandler:
MsgBox "An Error has Occured In The Form_Load() Procedure" & vbCr & "Report This
Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr & "Error Number
: " & Err.Number & vbCr & "Error Description : " & Err.Description, vbCritical,
"FlexGrid Example"
End Sub
ErrHandler:
MsgBox "An Error has Occured In The GETKEYSAdd() Procedure" & vbCr & "Report This
Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr & "Error Number
: " & Err.Number & vbCr & "Error Description : " & Err.Description, vbCritical,
"FlexGrid Example"
End Sub
ErrHandler:
MsgBox "An Error has Occured In The GETKEYSEdit() Procedure" & vbCr & "Report
This Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr & "Error
Number : " & Err.Number & vbCr & "Error Description : " & Err.Description,
vbCritical, "FlexGrid Example"
End Sub
'If FlexGrid's FixedCols is 1 then data should be assigned from the second column
is that argFlexGrid.col=1
argFlexGrid.Col = 1
argRS.MoveFirst
FormatString = "S.No."
'The Following loop is used for resizing the FlexGrid Columns using the
FormatString Property
'the MaxFldValLen variable stores the maximum length of a field's value
'and this variable is used to add spaces in the FormatString
'Note: This Resizing Is Not Very Accurate !!!
argRS.MoveNext
Next
argRS.MoveFirst
Next
'If FlexGrid's FixedCols is 0 then data should be assigned from the First column
is that argFlexGrid.col=0
argFlexGrid.Col = 0
argRS.MoveNext
Next
argRS.MoveFirst
'The Following loop is used for resizing the FlexGrid Columns using the
FormatString Property
'the MaxFldValLen variable stores the maximum length of a field's value
'and this variable is used to add spaces in the FormatString
'Note: This Resizing Is Not Very Accurate !!!
argRS.MoveNext
Next
argRS.MoveFirst
Else
'if MaxFldValLen(the maximum length of the field's value in a Record)
'is greater than the length of argRS(i).Name then,
'add the excess spaces is that Space(MaxFldValLen - Len(argRS(i).Name) + 15),
'the value 15 should not be changed for exact output
If FormatString = "" Then 'if this loop runs for first time then
FormatString will be empty
FormatString = argRS(i).Name & Space(MaxFldValLen - Len(argRS(i).Name) +
15)
Else
FormatString = FormatString & "|" & argRS(i).Name & Space(MaxFldValLen -
Len(argRS(i).Name) + 15)
End If
End If
Next
End If
ErrHandler:
MsgBox "An Error has Occured In The AssignData() Procedure" & vbCr & "Report This
Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr & "Error Number
: " & Err.Number & vbCr & "Error Description : " & Err.Description, vbYesNo +
vbCritical, "FlexGrid Example"
End Sub
Public Function FlexUpdate(argFlexGrid As MSFlexGrid, argRS As Recordset) As
Boolean
'This Procedure will Save the Data in the FlexGrid to the given
'Recordset's Database
On Error GoTo ErrHandler
Dim i As Long, j As Long
If argFlexGrid.Rows <= 1 Then Exit Function 'If there is no Row or Only FixedRow.
If FlexChk(argFlexGrid) = False Then 'Checking for empty cells by calling
FlexChk().
FlexUpdate = False
Exit Function
End If
argFlexGrid.Row = 0 'setting current row
argFlexGrid.Col = 0 'setting current col
argRS.AddNew
For i = 0 To (argFlexGrid.Rows - 1) 'This loop saves data to the table.
argFlexGrid.Row = argFlexGrid.Row + 1
argFlexGrid.Col = 0
For j = 0 To argRS.Fields.Count - 1
argRS(j) = Trim(argFlexGrid.Text)
If argFlexGrid.Col + 1 <> argFlexGrid.Cols Then
argFlexGrid.Col = argFlexGrid.Col + 1
End If
Next
argRS.UpdateBatch adAffectAllChapters
If argFlexGrid.Rows = (argFlexGrid.Row + 1) Then GoTo FIN
argRS.AddNew
Next
FIN:
argRS.UpdateBatch adAffectAllChapters
FlexUpdate = True
Exit Function
ErrHandler:
MsgBox "An Error has Occured In The FlexUpdate() Procedure" & vbCr & "Report This
Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr & "Error Number
: " & Err.Number & vbCr & "Error Description : " & Err.Description, vbCritical,
"FlexGrid Example"
End Function
For jg = 0 To (argFlexGrid.Rows - 1)
For ig = 0 To (argFlexGrid.Cols - 1)
If Len(Trim(argFlexGrid.TextMatrix(jg, ig))) = 0 Then
flg = True
GoTo EMTY
Else
flg = False
End If
Next
Next
EMTY:
If flg = True Then
FlexChk = False
Else
FlexChk = True
End If
Exit Function
ErrHandler:
MsgBox "An Error has Occured In The FlexChk() Procedure" & vbCr & "Report This
Error To issargur@yahoo.co.in" & vbCr & "Error Details :-" & vbCr & "Error Number
: " & Err.Number & vbCr & "Error Description : " & Err.Description, vbCritical,
"FlexGrid Example"
End Function
----------
Task: How to use Crystal report with MS-Access
cr1.SelectionFormula = ""
'cr1.SelectionFormula = {otmast.otid}='" & trim(text1.text) & "'"
cr1.WindowState = crptMaximized
cr1.Action = 1
cr1.PageZoom 89
============
Task: Send Mail Using Visual Basic
Dim cdoObj As CDO.Message
Dim iConf As CDO.Configuration
Dim str As String
Digg this!
Rate this article :
The Network card MAC address is a uniquely assigned code hardcoded into your
network card. The value is used by networks when transmitting information between
sources
Simply create a new VB6 project, add a new module and cut and paste the code below
into the module.
Then use the function GetMACAddress() to obtain the string value for the Network
card MAC Address
name_num As Integer
name_flags As Integer
End Type
Public Function GetMACAddress() As String 'retrieve the MAC Address for the
network controller
'installed, returning a formatted string
If pASTAT = 0 Then
Debug.Print "memory allocation failed!"
Exit Function
End If
NCB.ncb_buffer = pASTAT
Call Netbios(NCB)
GetMACAddress = tmp
End Function
* Join OSIX
* Get Involved
* Challenge or Test your skills
Comments:
Anonymous
2005-12-05 10:54:03
thanks a lot
Anonymous
2007-07-11 11:24:17
Thank for the code but there are few errors. The following is the corrected code
which can work on Win 2000 Server & Win Server 2003:
Option Explicit
name_num As Integer
name_flags As Integer
End Type
Public Function GetMACAddress() As String 'retrieve the MAC Address for the
network controller
'installed, returning a formatted string
If pASTAT = 0 Then
Debug.Print "memory allocation failed!"
Exit Function
End If
NCB.ncb_buffer = pASTAT
Call Netbios(NCB)
GetMACAddress = tmp
End Function
Anonymous
2007-07-18 05:26:38
lg
Michi
Anonymous
2007-08-27 07:18:54
I have the same problem. On some computer return real value and on some all zeros.
Any help?
Anonymous
2007-10-01 15:17:30
me too
Anonymous
2007-10-03 21:07:06
jajajaja
This thing it's belongs to microsoft... jjajajaja
http://support.microsoft.com/kb/175472
The revised code produces the right MAC on three of my newest PCs (all Vista) but
produces all zeros on my older XP boxes. Anybody understand why?
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:
Test Yourself: (why not try testing your skill on this subject? Clicking the link
will start the test.)