I have 2 line of codes in sorting a listview.
Try to add this codes to your listview_columnclick
listview1.sortkey = columnheader.index - 1
lstview1.sorted = true
Monday, October 20, 2008
Sunday, August 31, 2008
Populate ListView from SQL Server
Hello to all.
Today my sample is all above listview. Populate listview of data from database.
If you have ur connectionstring and recordset. Then set 1 listview and 1 commandbutton.
In your command button insert this code:
Dim Item as ListItem 'variable for your subitems
ListView1.ListItems.Clear 'Clear your Listview before loading a new data
While Not rs.eof
Set Item = ListView1.ListItems.Add(,,rs!One)
Item.Subitems(1) = rs!Two
rs.movenext
Wend
Hope this one will help you
Today my sample is all above listview. Populate listview of data from database.
If you have ur connectionstring and recordset. Then set 1 listview and 1 commandbutton.
In your command button insert this code:
Dim Item as ListItem 'variable for your subitems
ListView1.ListItems.Clear 'Clear your Listview before loading a new data
While Not rs.eof
Set Item = ListView1.ListItems.Add(,,rs!One)
Item.Subitems(1) = rs!Two
rs.movenext
Wend
Hope this one will help you
Thursday, August 21, 2008
Numeric only in Textbox
I have function code here. To restrict the input in textbox only for numeric.
Public Function OnlyNumericKeys(KeyAscii As Integer, TextBox As control) As Integer
Select Case KeyAscii
Case 8, 48 To 57, 46 And InStr(TextBox, ".") = 0
Case 45 And InStr(TextBox, "-") = 0
If TextBox.SelStart > 0 Then
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
OnlyNumericKeys = KeyAscii
End Function
Thanks for the help of my friend (mike).
Public Function OnlyNumericKeys(KeyAscii As Integer, TextBox As control) As Integer
Select Case KeyAscii
Case 8, 48 To 57, 46 And InStr(TextBox, ".") = 0
Case 45 And InStr(TextBox, "-") = 0
If TextBox.SelStart > 0 Then
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
OnlyNumericKeys = KeyAscii
End Function
Thanks for the help of my friend (mike).
Removing Maximize Button
Hello there.
This API Codes will help you to remove the maximize button in form.
Public Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Public Const GWL_STYLE = (-16)
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Hope this one can help.
This API Codes will help you to remove the maximize button in form.
Public Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Public Const GWL_STYLE = (-16)
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Hope this one can help.
How to Center a Form
Try this code. Hope it can help.
In your module copy then paste this code:
Public Sub CenterForm(f As Form, w)
f.Left = (w.ScaleWidth - f.Width) / 2
f.Top = (w.ScaleHeight - f.Height) / 2
End Sub
In your Form Load:
Private Sub Form_Load()
CenterForm Me, Main
End Sub
This code will centering your form in mdiparent
In your module copy then paste this code:
Public Sub CenterForm(f As Form, w)
f.Left = (w.ScaleWidth - f.Width) / 2
f.Top = (w.ScaleHeight - f.Height) / 2
End Sub
In your Form Load:
Private Sub Form_Load()
CenterForm Me, Main
End Sub
This code will centering your form in mdiparent
User System Login
Hi.
Sample code in System Login. And theres a 3 attempt to log.
Set rs = BASACONN(connstr, "select * from usersettings where username=txtuser and password=txtpassword")
If rs.EOF Then
MsgBox "Invalid Username/Password. Please Try again", vbExclamation, "Invalid"txtusername.SetFocus
txtcount.Text = Val(txtcount.Text) + 1
'''wrong password
If Val(txtcount.Text) > 2 Then
MsgBox "You have 3 Invalid Input of Username/Password. This Program will terminate",vbCritical, "Exit Program"
End
End If
''end
Else
Unload Me
Main.Show
Endif
Sample code in System Login. And theres a 3 attempt to log.
Set rs = BASACONN(connstr, "select * from usersettings where username=txtuser and password=txtpassword")
If rs.EOF Then
MsgBox "Invalid Username/Password. Please Try again", vbExclamation, "Invalid"txtusername.SetFocus
txtcount.Text = Val(txtcount.Text) + 1
'''wrong password
If Val(txtcount.Text) > 2 Then
MsgBox "You have 3 Invalid Input of Username/Password. This Program will terminate",vbCritical, "Exit Program"
End
End If
''end
Else
Unload Me
Main.Show
Endif
Monday, June 16, 2008
How to use Drivelistbox, Dirlistbox and Filelistbox
Good Day to my visitor. This sample codes all about Drivelistbox, Dirlistbox and Filelistbox. In this example you will learn on how to use these 3 basic controls in Visual Basic 6.
First Step: Create new project in Visual Basic 6. Then Input a Controls in Form1.
*label1, filename , Drivelistbox, Dirlistbox, and Filelistbox.
Second Step: Write these following codes.
Private Sub DirListBox_Change()
FileListBox.Path = DirListBox.Path
End Sub
Private Sub FileListBox_Click()
filename.Caption = FileListBox.filename
End Sub
Private Sub DriveListBox_Change()
Dim msg As String
Dim result As String
On Error GoTo Error
DirListBox.Path = DriveListBox.Drive
Exit Sub
Error:msg = "Error: " & Err.Number & ": " & Err.Description
result = MsgBox(msg, vbOKCancel + vbExclamation , "No Data")
If result = vbOK Then
Resume
Else
DriveListBox.Drive = DirListBox.Path
Err.Clear
Exit Sub
End If
End Sub
First Step: Create new project in Visual Basic 6. Then Input a Controls in Form1.
*label1, filename , Drivelistbox, Dirlistbox, and Filelistbox.
Second Step: Write these following codes.
Private Sub DirListBox_Change()
FileListBox.Path = DirListBox.Path
End Sub
Private Sub FileListBox_Click()
filename.Caption = FileListBox.filename
End Sub
Private Sub DriveListBox_Change()
Dim msg As String
Dim result As String
On Error GoTo Error
DirListBox.Path = DriveListBox.Drive
Exit Sub
Error:msg = "Error: " & Err.Number & ": " & Err.Description
result = MsgBox(msg, vbOKCancel + vbExclamation , "No Data")
If result = vbOK Then
Resume
Else
DriveListBox.Drive = DirListBox.Path
Err.Clear
Exit Sub
End If
End Sub
Wednesday, May 14, 2008
How to Clear all Text in a TextBox
First create a variable:
Dim Sayre As Control
Then Type this code in a Button:
For Each sayre In Me
If TypeOf sayre Is TextBox Then
sayre.Text = ""
End If
Next
####################################
Private Sub Command1_Click()
Dim sayre As Control
For Each sayre In Me
If TypeOf sayre Is TextBox Then
sayre.Text = ""
End If
Next
End Sub
####################################
Dim Sayre As Control
Then Type this code in a Button:
For Each sayre In Me
If TypeOf sayre Is TextBox Then
sayre.Text = ""
End If
Next
####################################
Private Sub Command1_Click()
Dim sayre As Control
For Each sayre In Me
If TypeOf sayre Is TextBox Then
sayre.Text = ""
End If
Next
End Sub
####################################
Labels:
Clear,
Clear all Text,
Erase,
History of Visual Basic 6,
Textbox,
VB6
Thursday, April 10, 2008
Visual Basic 6.0
Visual Basic (VB) is a third-generation event driven programming language and associated development environment from Microsoft for its COM programming model.[1] Visual Basic was derived from BASIC and enables the rapid application development (RAD) of graphical user interface (GUI) applications, access to databases using DAO, RDO, or ADO, and creation of ActiveX controls and objects. Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic, but perform differently.[2]
A programmer can put together an application using the components provided with Visual Basic itself. Programs written in Visual Basic can also use the Windows API, but doing so requires external function declarations.
In business programming, Visual Basic has one of the largest user bases. In a survey conducted in 2005, 62 percent of developers reported using some form of Visual Basic. It currently competes with C++, C# and Java for dominance in the business world. JavaScript is another competitor to Visual Basic.[3]
The final release was version 6 in 1998. Microsoft extended support will end in 2008 and the designated successor is Visual Basic .NET.
A programmer can put together an application using the components provided with Visual Basic itself. Programs written in Visual Basic can also use the Windows API, but doing so requires external function declarations.
In business programming, Visual Basic has one of the largest user bases. In a survey conducted in 2005, 62 percent of developers reported using some form of Visual Basic. It currently competes with C++, C# and Java for dominance in the business world. JavaScript is another competitor to Visual Basic.[3]
The final release was version 6 in 1998. Microsoft extended support will end in 2008 and the designated successor is Visual Basic .NET.
Other Information Click Me. - Topics from en.wikipedia.org
Subscribe to:
Posts (Atom)