Recent Posts

Friday, April 11, 2008

Display data continuously in Big Screen From VB

Dim objRst As New ADODB.Recordset
Dim objCnn As ADODB.Connection

Private Sub Form_Load() 'Me.ShockwaveFlash1.Movie = App.Path & "\display.swf"
Set objCnn = New ADODB.Connection
objCnn.Open "test", "test", "test"

Me.Visible = True
fontfield
End Sub

Private Sub Display()
On Error GoTo ErrD
Dim strSex As String
Dim strStatus As String
Do While Not objRst.EOF
Clearfield

strSex = objRst!SEX


If objRst!Status = "E" Then
strStatus = "Elected"
Else
strStatus = ""
End If
Me.lblDist(0).Caption = objRst!distname_en
Me.lblConst(0).Caption = objRst!Const
Me.lblCand(0).Caption = objRst!cfname_en
Me.lblSex(0).Caption = strSex
Me.lblname(0).Caption = objRst!short_name_en
Me.lblTotal(0).Caption = objRst!total
Me.lblStatus(0).Caption = strStatus

Me.lblDist(10).Caption = objRst!distname_en
Me.lblConst(10).Caption = objRst!Const
Me.lblCand(10).Caption = objRst!cfname_en
Me.lblSex(10).Caption = strSex
Me.lblname(10).Caption = objRst!short_name_en
Me.lbltotal(10).Caption = objRst!totalvote
Me.lblStatus(10).Caption = strStatus



If Not objRst.EOF Then
objRst.MoveNext
End If
If Not objRst.EOF Then


strSex = objRst!SEX

Me.lblDist(1).Caption = ""
Me.lblConst(1).Caption = ""
Me.lblCand(1).Caption = objRst!cfname_en
Me.lblSex(1).Caption = strSex
Me.lblParty(1).Caption = objRst!short_name_en
Me.lblVote(1).Caption = objRst!totalvote
Me.lblStatus(1).Caption = ""

Me.lblDist(11).Caption = ""
Me.lblConst(11).Caption = ""
Me.lblCand(11).Caption = objRst!cfname_en
Me.lblSex(11).Caption = strSex
Me.lblParty(11).Caption = objRst!short_name_en
Me.lblVote(11).Caption = objRst!totalvote
Me.lblStatus(11).Caption = ""


End If

If Not objRst.EOF Then
objRst.MoveNext
End If

If Not objRst.EOF Then


strSex = objRst!SEX
If objRst!Status = "E" Then
strStatus = "Elected"
Else
strStatus = ""
End If

Me.lblDist(2).Caption = objRst!distname_en
Me.lblConst(2).Caption = objRst!Const
Me.lblCand(2).Caption = objRst!cfname_en
Me.lblSex(2).Caption = strSex
Me.lblParty(2).Caption = objRst!short_name_en
Me.lblVote(2).Caption = objRst!totalvote
Me.lblStatus(2).Caption = strStatus

Me.lblDist(12).Caption = objRst!distname_en
Me.lblConst(12).Caption = objRst!Const
Me.lblCand(12).Caption = objRst!cfname_en
Me.lblSex(12).Caption = strSex
Me.lblParty(12).Caption = objRst!short_name_en
Me.lblVote(12).Caption = objRst!totalvote
Me.lblStatus(12).Caption = strStatus

End If


If Not objRst.EOF Then
objRst.MoveNext
End If
If Not objRst.EOF Then


strSex = objRst!SEX

Me.lblDist(3).Caption = ""
Me.lblConst(3).Caption = ""
Me.lblCand(3).Caption = objRst!cfname_en
Me.lblSex(3).Caption = strSex
Me.lblParty(3).Caption = objRst!short_name_en
Me.lblVote(3).Caption = objRst!totalvote
Me.lblStatus(3).Caption = ""

Me.lblDist(13).Caption = ""
Me.lblConst(13).Caption = ""
Me.lblCand(13).Caption = objRst!cfname_en
Me.lblSex(13).Caption = strSex
Me.lblParty(13).Caption = objRst!short_name_en
Me.lblVote(13).Caption = objRst!totalvote
Me.lblStatus(13).Caption = ""
End If
If Not objRst.EOF Then
objRst.MoveNext
End If
If Not objRst.EOF Then


strSex = objRst!SEX

If objRst!Status = "E" Then
strStatus = "Elected"
Else
strStatus = ""
End If

Me.lblDist(4).Caption = objRst!distname_en
Me.lblConst(4).Caption = objRst!Const
Me.lblCand(4).Caption = objRst!cfname_en
Me.lblSex(4).Caption = strSex
Me.lblParty(4).Caption = objRst!short_name_en
Me.lblVote(4).Caption = objRst!totalvote
Me.lblStatus(4).Caption = strStatus

Me.lblDist(14).Caption = objRst!distname_en
Me.lblConst(14).Caption = objRst!Const
Me.lblCand(14).Caption = objRst!cfname_en
Me.lblSex(14).Caption = strSex
Me.lblParty(14).Caption = objRst!short_name_en
Me.lblVote(14).Caption = objRst!totalvote
Me.lblStatus(14).Caption = strStatus

End If


If Not objRst.EOF Then
objRst.MoveNext
End If
If Not objRst.EOF Then


strSex = objRst!SEX

Me.lblDist(5).Caption = ""
Me.lblConst(5).Caption = ""
Me.lblCand(5).Caption = objRst!cfname_en
Me.lblSex(5).Caption = strSex
Me.lblParty(5).Caption = objRst!short_name_en
Me.lblVote(5).Caption = objRst!totalvote
Me.lblStatus(5).Caption = ""

Me.lblDist(16).Caption = ""
Me.lblConst(16).Caption = ""
Me.lblCand(16).Caption = objRst!cfname_en
Me.lblSex(16).Caption = strSex
Me.lblParty(16).Caption = objRst!short_name_en
Me.lblVote(16).Caption = objRst!totalvote
Me.lblStatus(16).Caption = ""
End If
'------------------
If Not objRst.EOF Then
objRst.MoveNext
End If
If Not objRst.EOF Then



strSex = objRst!SEX
If objRst!Status = "E" Then
strStatus = "Elected"
Else
strStatus = ""
End If
Me.lblDist(6).Caption = objRst!distname_en
Me.lblConst(6).Caption = objRst!Const
Me.lblCand(6).Caption = objRst!cfname_en
Me.lblSex(6).Caption = strSex
Me.lblParty(6).Caption = objRst!short_name_en
Me.lblVote(6).Caption = objRst!totalvote
Me.lblStatus(6).Caption = strStatus

Me.lblDist(15).Caption = objRst!distname_en
Me.lblConst(15).Caption = objRst!Const
Me.lblCand(15).Caption = objRst!cfname_en
Me.lblSex(15).Caption = strSex
Me.lblParty(15).Caption = objRst!short_name_en
Me.lblVote(15).Caption = objRst!totalvote
Me.lblStatus(15).Caption = strStatus

End If


If Not objRst.EOF Then
objRst.MoveNext
End If
If Not objRst.EOF Then


strSex = objRst!SEX

Me.lblDist(7).Caption = ""
Me.lblConst(7).Caption = ""
Me.lblCand(7).Caption = objRst!cfname_en
Me.lblSex(7).Caption = strSex
Me.lblParty(7).Caption = objRst!short_name_en
Me.lblVote(7).Caption = objRst!totalvote
Me.lblStatus(7).Caption = ""

Me.lblDist(17).Caption = ""
Me.lblConst(17).Caption = ""
Me.lblCand(17).Caption = objRst!cfname_en
Me.lblSex(17).Caption = strSex
Me.lblParty(17).Caption = objRst!short_name_en
Me.lblVote(17).Caption = objRst!totalvote
Me.lblStatus(17).Caption = ""
End If


If Not objRst.EOF Then
objRst.MoveNext
End If
If Not objRst.EOF Then


strSex = objRst!SEX

If objRst!Status = "E" Then
strStatus = "Elected"
Else
strStatus = ""
End If

Me.lblDist(8).Caption = objRst!distname_en
Me.lblConst(8).Caption = objRst!Const
Me.lblCand(8).Caption = objRst!cfname_en
Me.lblSex(8).Caption = strSex
Me.lblParty(8).Caption = objRst!short_name_en
Me.lblVote(8).Caption = objRst!totalvote
Me.lblStatus(8).Caption = strStatus


Me.lblDist(18).Caption = objRst!distname_en
Me.lblConst(18).Caption = objRst!Const
Me.lblCand(18).Caption = objRst!cfname_en
Me.lblSex(18).Caption = strSex
Me.lblParty(18).Caption = objRst!short_name_en
Me.lblVote(18).Caption = objRst!totalvote
Me.lblStatus(18).Caption = strStatus

End If


If Not objRst.EOF Then
objRst.MoveNext
End If
If Not objRst.EOF Then


strSex = objRst!SEX

Me.lblDist(9).Caption = ""
Me.lblConst(9).Caption = ""
Me.lblCand(9).Caption = objRst!cfname_en
Me.lblSex(9).Caption = strSex
Me.lblParty(9).Caption = objRst!short_name_en
Me.lblVote(9).Caption = objRst!totalvote
Me.lblStatus(9).Caption = ""


Me.lblDist(19).Caption = ""
Me.lblConst(19).Caption = ""
Me.lblCand(19).Caption = objRst!cfname_en
Me.lblSex(19).Caption = strSex
Me.lblParty(19).Caption = objRst!short_name_en
Me.lblVote(19).Caption = objRst!totalvote
Me.lblStatus(19).Caption = ""
End If

If Not objRst.EOF Then
objRst.MoveNext
End If
DoEvents
DoEvents
Sleep 10000


Loop
objRst.Close
Set objRst = Nothing
DisplayAgain
Exit Sub

ErrD:
' If gDatabase.LastServerErr <> 0 Then
'
' If gDatabase.LastServerErr = 1000 Then
' gDatabase.Close
' Set gdtabase = Nothing
' Set gSession = Nothing
' Set obj = Nothing
' GlobalMod.CreateSession DbName, "ledentry/entry"
' DisplayAgain
' Exit Sub
' End If
' strMsg = OracleError.OracleError(gDatabase.LastServerErr)
' If strMsg = "" Then
' strMsg = "Error: " & gDatabase.LastServerErrText & vbNewLine
' strMsg = strMsg & "Cause: " & "Not Known" & vbNewLine
' strMsg = strMsg & "Action: Contact your Administrator"
' End If
'
' End If
MsgBox strMsg, vbInformation, "Database Error"


End Sub
Private Sub DisplayAgain()
If objRst.State = 1 Then
objRst.Close
End If
objRst.Open "SELECT a.CONST, CFNAME_en, SEX, TOTALVOTE, a.STATUS, DISTNAME_en, SHORT_NAME_en From FPTPTOPN_en a where r<=2 order by a.district,a.const,r", objCnn, adOpenStatic 'and status in('C','E')
Display

End Sub

Private Sub txts_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 8 Then
End
Else
DisplayAgain
End If
End Sub
Private Sub Clearfield()
Dim i As Integer
For i = 0 To 19
Me.lblCand(i).Caption = ""
Me.lblConst(i).Caption = ""
Me.lblDist(i).Caption = ""
Me.lblParty(i).Caption = ""
Me.lblSex(i).Caption = ""
Me.lblStatus(i).Caption = ""
Me.lblVote(i).Caption = ""
Next
End Sub


Private Sub fontfield()
Dim i As Integer
For i = 0 To 19
Me.lblCand(i).FontName = "Verdana"
Me.lblCand(i).FontBold = False
Me.lblConst(i).FontName = "Verdana"
Me.lblConst(i).FontBold = False
Me.lblDist(i).FontName = "Verdana"
Me.lblDist(i).FontBold = False
Me.lblParty(i).FontName = "Verdana"
Me.lblParty(i).FontBold = False
Me.lblSex(i).FontName = "Verdana"
Me.lblSex(i).FontBold = False
Me.lblStatus(i).FontName = "Verdana"
Me.lblStatus(i).FontBold = False
Me.lblVote(i).FontName = "Verdana"
Me.lblVote(i).FontBold = False

Me.lblCand(i).FontSize = 16
Me.lblConst(i).FontSize = 16
Me.lblDist(i).FontSize = 16
Me.lblParty(i).FontSize = 16
Me.lblSex(i).FontSize = 16
Me.lblStatus(i).FontSize = 16
Me.lblVote(i).FontSize = 16
Next
End Sub


Read more!

Wednesday, April 9, 2008

Set Window OnTop in VB 6 Application

Get free code to get your vb 6 application form to sit on top of other forms in your application. 
This code will be very helpful for most of the visual basic softwares. Even you can modify the code and use it in vb net , asp net or c# net applications. 

' Declarations

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40

' declaring the api 

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long



Private Sub SetWindowOnTop(f As Form, bAlwaysOnTop As Boolean)
Dim iFlag As Long

iFlag = IIf(bAlwaysOnTop, HWND_TOPMOST, HWND_NOTOPMOST)

SetWindowPos f.hwnd, iFlag, f.Left / Screen.TwipsPerPixelX, f.Top /

Screen.TwipsPerPixelY, _
f.Width / Screen.TwipsPerPixelX, f.Height / Screen.TwipsPerPixelY,
SWP_NOACTIVATE Or SWP_SHOWWINDOW
End Sub


'call the function on form load from vb application
SetWindowOnTop Me, True

' True in the end of the function puts the window on top of other forms


Read more!

Tuesday, April 1, 2008

FTP files from VB 6

Private Sub Command1_Click()
' Simple FTP Sample
' This is written in VB 6. You need to include
' Microsoft Internet Transfer Control 6.0 (MSINET.OCX)
' in your code (referred to as Inet1 in this code).
'
'
'Obviously you will need to change the values used below to the
'ones that suit your needs

' First make an FTP Site in IIS for testing and put
' file named pra.htm in the ftp site
' and file named pra.txt in the c:

Inet1.AccessType = icUseDefault
' URL of FTP Site goes here.
Inet1.URL = "ftp://192.168.10.89"
Inet1.UserName = "db2admin"
Inet1.Password = "commission"

Inet1.RequestTimeout = 40
' GET Command here.
' download pra.htm and place it on c:\pra.htm

Inet1.Execute , "GET pra.htm c:\pra.htm"

'Put Command here.
'Upload c:\pra.txt and place it on FTP Site

'Inet1.Execute , "PUT c:\pra.txt pra.txt"

Do While Inet1.StillExecuting
DoEvents
Loop
Inet1.Execute , "CLOSE"
MsgBox ("Update Completed")

End Sub


Read more!

Issuing FTP Commands

Issuing FTP Commands


The Internet Transfer control will automatically establish an FTP session the first time you execute an FTP command. Table 11.5 lists the FTP commands for the control.

Table 11.5: FTP Commands for the Internet Transfer Control

FTP Command Description
CD dir Changes the current directory to the specified directory on the remote computer
CDUP Changes the current directory to the parent directory on the remote computer
CLOSE Closes the connection to the remote computer
DELETE file Deletes the specified file on the remote computer
DIR [dir] Returns the list of files from the specified directory (use GetChunk to get the information)
GET file1 file2 Retrieves the specified file (file1) from the remote computer and saves it as the specified file (file2) on the local computer
LS [dir] Same as DIR
MKDIR dir Creates the specified directory on the remote computer
PUT file1 file2 Sends the specified file (file1) from the local computer and saves it as the specified file (file2) on the remote computer
PWD Returns the current directory from the remote computer (use GetChunk to get the information)
QUIT Terminates the current user’s session on the remote computer
RECV file1 file2 Same as GET
RENAME file1 file2 Changes the name of the specified file (file1) to the specified name (file2) on the remote computer
RMDIR dir Deletes the specified directory
SEND file1 file2 Same as PUT
SIZE dir Returns the size of the specified directory (use GetChunk to get the information)

WARNING: Security, security, security: Just because a command is listed here does not mean it can be used. Your user name and password will determine your level of access to the files on the server, as well as which commands you will be able to execute.

Closing a Session

The session will remain active until you explicitly close it with the Quit or Close commands. If you used the Quit command to log on as a different user, then you need to update the values in UserName and Password properties before you issue the next command.

Sending and Receiving Files

You can send a file to the remote computer by using the PUT command. The PUT command has two parameters: the name of the file on the local computer and the name of the file on the remote computer. Both are required to successfully transfer a file. The SEND command is another name for the PUT command.

The GET command works the same as the PUT command, but it retrieves a file from the remote machine. Two parameters are required for this command also. The first parameter is the name of the remote file, and the second is the name of the local file. Like the PUT command, both parameters are required to successfully transfer the file. The RECV command is a synonym for the GET command.

Working with Directories

One of the side effects of a session-oriented protocol like FTP is that the server can remember certain information from one command to the next. So commands like CD, CDUP, and PWD allow you to traverse the directory structure on the remote computer and let you specify filenames relative to the current working directory.

You can also create and delete directories using the MKDIR and RMDIR commands. You can retrieve a list of files using the DIR command. (Note that the LS command is a synonym for the DIR command.) When using the DIR command, you need to use the GetChunk method to retrieve the contents of the directory. The chunk of information returned is merely a list of files in the current directory on the remote system. Each file is listed on a single line with a carriage return/line feed pair between them. No size or other information is returned in this value. (Note that you can also specify the name of a file or directory, and that information will be returned in place of the list of files in the current working directory.)


Read more!