Getting diskspace of a drive in vb6

create a button in form and use the below code. Option Explicit Private Declare Function GetDiskFreeSpace Lib “kernel32″ Alias _ “GetDiskFreeSpaceA” (ByVal lpRootPathName As String, _ lpSectorsPerCluster As Long, lpBytesPerSector As Long, _ lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long Private Sub Command1_Click() Dim Sectors As Long, Bytes As Long, FreeC As Long, TotalC…


creating MS Excel and writing cells in VB6

Private Sub Command2_Click() Dim rowinc As Integer Dim excelApp As Excel.Application Dim excelWB As Excel.Workbook Set excelApp = CreateObject(“Excel.Application”) Set excelWB = excelApp.Workbooks.Add Dim excelWS As Excel.Worksheet Set excelWS = excelWB.Worksheets(1) excelWS.Cells(1, 1).Value = “S.No” excelWS.Cells(1, 1).Borders(xlEdgeBottom).LineStyle = xlContinuous ‘ Used to create border excelWS.Cells(1, 1).Borders(xlEdgeLeft).LineStyle = xlContinuous excelWS.Cells(1, 1).Borders(xlEdgeTop).LineStyle = xlContinuous excelWS.Cells(1, 1).Borders(xlEdgeRight).LineStyle =…


reading a file in VB6 using file system object

Dim myFSO As Scripting.FileSystemObject
Dim myTextStream As Scripting.TextStream
Dim myString As String

Set myFSO = New Scripting.FileSystemObject

If myFSO.FileExists("filepath.txt") Then
Set myTextStream = myFSO.OpenTextFile("filepath.txt", ForReading)
myString = myTextStream.ReadAll() ' file content will be available in myString
Call myTextStream.Close
End If

Set myTextStream = Nothing
Set myFSO = Nothing

Load values to dropdown\Combo from Database in VB6

Add a combo control in the form with name combo2. And use the below code to load the values. Private Sub Form_Load() Dim cn1 As Object Dim rs1, rs2 As Object Set cn1 = CreateObject(“ADODB.Connection”) strConnection = “Provider=Microsoft.ACE.OLEDB.12.0;” & “Data Source=” & “file path” & “Data.mdb” strSql = “SELECT * FROM User_Login;” cn1.Open strConnection Set…


connecting with MS Access database in VB6 through ADODB.Connection

Dim cn As Object Dim rst As Object Dim strConnection As String Dim strSql As String Set cn = CreateObject(“ADODB.Connection”) strConnection = “Provider=Microsoft.ACE.OLEDB.12.0;” & “Data Source=” & “path of the file” & “Data.mdb” strSql = “SELECT * FROM User_Login where User_Id=’username';” cn.Open strConnection Set rst = cn.Execute(strSql) If rst.BOF And rst.EOF Then MsgBox “No data…


Sending mail in VB6 using SMTP

Mail Without Attachment Dim mail As New MailMessage() mail.To = “” mail.From = “” mail.Subject = “Enter any subject here.” mail.BodyFormat = MailFormat.Html mail.Body = “Mail body here” SmtpMail.SmtpServer = “localhost” ‘smtp server details SmtpMail.Send(mail) Mail With Attachment Dim mail As New MailMessage() mail.To = “” mail.From = “” mail.Subject = “Enter any subject here.”…