VB calculator code

This article is mainly for the beginners. I am trying to explain the use of Control Arrays with the help of Calculator Sample.I feel control arrays are overlooked  in classic visual basic. if the way to implement is understood, it is much useful in reducing the code. Control Arrays can be used in the situations like whenever the need of same controls being used several times in an application. We can make them as an array, and the controls can be accessed by their index in all the respective events

VB 6 Control Arrays in form

As shown in the following figure, Design the form. Create a Command Button named as Command1 and copy that and paste it 11 times. This will create a control array.
Then assign the text as shown in the figure. all the controls under red boxes are under one group. So design it accordingly.

like wise create cmdOperator control array for the green box group.

Sample Program to retrieve the response from a web page Using XML HTTP

This is a sample function to retrieve the response from a webpage using XML HTTP Object

1. First we need to declare and create an instance of xmlHttp
Dim xHttp As New xmlHttp
2. Then use the open method to fetch the data from the url(fetch if GET)
xHttp.open "GET", strUrl, False
3. then invoke the send method to perform the action specified in the open method

Using xmlHttp we can submit forms, get the data from the web pages, download files and upload files and more.

Private Sub Form_Load()
    MsgBox GetWebResponse("http://www.vbknowledgebase.com")
End Sub
Public Function GetWebResponse(ByVal strUrl As String) ...

Read more here:   Get Web Response xmlHttp 

VB6 Send Email Using SMTP and CDO

In enterprise application sending email from applications is a inevitable task. Particularly for notifications emails are one of the best medium to communicate.Normally the SMTP server will be in seperate location and reachable from application server or web servers. In this scenerio we need to specify to CDO which SMTP server we are going to use. Then only the relay will be succesful.

This is a simple code to send email from applications. Now this function supports CC, BCC and attachments.

Read more here:   Send Email(E-Mail) from VB6 using CDO 

Implicit Connections in ADO with Visual Basic 6

When a same connection is used to open two different RecordSets, ADO opens
two ports (TCP/IP) in the machine where application is running. If a RecordSet is opening inside a loop with the same connection then ado will open a separate port for its each iteration


1.      Use a separate connection for each RecordSets rather than using the same
connection as follows.
Dim conOne as new Adodb.Connection
Dim rsOne as Adodb.Recordset
Dim rsTwo as Adodb.Recordset
conOne.open(connection string goes here)
Set rsOne= con.execute select query
Do until rsOne.EoF
                Set rsTwo = conOne.execute select c2,c3 from tbl1 where
c1 = & rsOne(0)
                rsOne.M ...

Read more here:   Implicit connections 

Spam Bot Trap


Select Theme