This tutorial is about some basic concepts in Computer Science and programming with Visual Basic and C++.
Thought Sharing
Thursday, April 28, 2011
Swaping Two Numbers using third variable (VB 6.0)
Private Sub Command1_Click ()
Dim a As Integer
Dim b As Integer
Dim temp As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
temp = b
b = a
a = temp
Text1.Text = a
Text2.Text = b
End Sub
Sunday, April 24, 2011
List of Programs for OOPs Practical File
1. WAP to find the sum of two numbers using function.
2. WAP to find Simple Interest and Compound Interest.
3. WAP to demonstrate the working of following Loops:
While, Do While, For,If-Else, Switch.
4. WAP to find greatest of three numbers.
5. WAP to check whether a number is even or odd.
6. WAP to check whether a year is leap year or not.
7. WAP to add and subtract two matrices.
8. WAP to display elements of an array.
9. WAP to calculate Sum and Average of an array.
10. WAP to sort elements of an array using Bubble sort.
11. WAP to calculate Factorial of a number.
12. WAP to check whether a given number is Prime or not.
13. WAP to generate Fibonacci series.
14. WAP to show function Overloading.
15. WAP to create a class and access member function of a class.
Friday, February 25, 2011
Sum and Averaage of elements of Array in C++
#include
#include
void main()
{
int n ,a[20],sum=0,avg;
clrscr();
cout<<"enter size of array: ";
cin>>n;
cout<<"Enter elements of Array: ";
for(int i=0;i
cin>>a[i];
}
cout<<"sum of elements of array: ";
for(i=0;i
sum=sum+a[i];
}
cout<
avg=sum/n;
cout<
}
FACTORIALS OF A NUMBER IN C++
#include
#include
void main()
{
clrscr();
int n, fact=1;
cout<<"Enter the number: ";
cin>>n;
for ( int i=1; i<=n; i++)
{
fact= fact * i;
cout<
cout<<"Factorial of this number is: ";
cout<
}
Tuesday, November 23, 2010
Database connectivity using ADO (ActiveX data Object)
Database connectivity using ADO (ActiveX data Object)
To be able to access and manage a database, you need to connect the ADO data control to a database file. We are going to use BIBLIO.MDB that comes with VB6. To connect ADO to this database file, follow the steps below:
1.) Open a new VB project and from the Components window (by clicking Project -> Components menu), select Microsoft Activex Data Control 6.0 (OLEDB) and click OK. ADO data control will appear in the toolbox.
2.) From toolbox, Drag & Drop Activex Data object data control (ADODC1) on your form.
3.) Click on the ADO control on the form and it will open the properties window.
4.) Click on the General tab and check the ConnectionString property
When the dialog box appears, select the Use Connection String's Option. Next, click build command button and at the Data Link Properties window, double-Click the option Microsoft Jet 3.51 OLE DB provider.
After that, click the Next button to select the database name BIBLO.MDB. You can click on Test Connection button to ensure proper connection of the database file. A messagebox will appear, Click OK to finish the connection.
5.) Finally, click on the RecordSource property and set the command type to adCmd Table and Table name to Customers. Now you are ready to use the database file.
6.) Drag & Drop a Textbox control (Text1) on your form, and set the properties as follows:
DataSourceName: Select ADO data control name: ADODC1
DataField: Select field of table to be displayed: CustomerID
7.) Now repeat the above step for all other text boxes on the form to set their DataSource, and DataField properties.
8.) Run the form by pressing F5 key.
Database connectivity using RDO (Remote data Object)
RDO uses ODBC (Open Data Base Connectivity), an ODBC Data Source, which must be set up through the Windows Control Panel. Follow the steps below to set up an ODBC Data Source (this process is also called "setting up a DSN", where "DSN" stands for "Data Source Name").The following steps is used to setup system DSN as:
1.) Go to Start -> Windows Control Panel; double-click on Administrative Tools, then Data Sources (ODBC). The ODBC Data Source Administrator screen is displayed. Click on the System DSN tab.
1.) Start a new VB project, and from the Components dialog box (invoked from the Project -> Components menu), select Microsoft Remote Data Control 6.0 (SP3) as shown below and click OK.
2.) Drag & Drop a remote data control (RDC) on your form, and set the properties as follows
DataSourceName: Select the DSN name as created above. Eg. Biblio
SQL: select * from Customers
3.) Now put text boxe on the form, and set DataSource, and DataField properties as follows:
DataSource: MSRDC1
DataField: CustomerName
4.) Save and run the program. It works just like the other data control.
Private Sub Command1_Click()
MSRDC1.Resultset.AddNew
End Sub
======================
Private Sub Command2_Click()
MSRDC1.Resultset.Delete
End Sub
Private Sub Command3_Click()
MSRDC1.Resultset.MoveFirst
End Sub
Private Sub Command4_Click()
MSRDC1.Resultset.Update
End Sub
Private Sub Command5_Click()
MSRDC1.Resultset.Edit
End Sub
Private Sub Command6_Click()
MSRDC1.Resultset.MovePrevious
End Sub
Private Sub Command7_Click()
MSRDC1.Resultset.MoveFirst
End Sub
Private Sub Command8_Click()
MSRDC1.Resultset.MoveLast
End Sub
Database connectivity using DAO (Data Access Object) i.e. Data Control (Data1)
1.) Open visual basic application. Drag & drop a data control (Data1) and textboxes on the form.
2.) For Data control (Data1) specify two properties :
i.) DatabaseName: specify the name of database. Eg. Nwind.mdb
ii.) RecordSource: specify the name of table you want to connect to. Eg. Customers
3.) Now for displaying data in textboxes, we need to specify two properties:
i.) DataSourceName: specify the name of data control (Data1)
ii.) Datfield: specify the name of the field of table whose data is to be displayed in this textbox. For eg. Customer Name.
4.) Repeat the above step for all the data bound controls i.e. textboxes on the form.
5.) Now run the form by pressing F5 key, to show the data of Customer Table.
List of Programs for Visual Basic Practical
1. Login page
2. Registration form
3. Calculator
4. Comparison b/w two no, Comparison b/w 3 no
5. Display pattern of counting
6. Display the table of 2.
7. Display the table of any number
8. Pattern of alphabets in serial order and in reverse order (eeeee,dddd,ccc,bb,a)
9. Pattern of alphabets in serial and reverse order (a,ab,abc,abcd,abcde)
10. Pattern of stars (*,**,***,****,*****): in serial and reverse order
11. To check where a number is Prime or Not.
12. Check no is even or odd
13. Check the year is leap year or not
14. Calculate compound interest
15. Calculate simple interest
16. Factorial of a number
17. To check a string is palindrome or not
18. Traffic light signal using Timer control
19. Storing and displaying 10 numbers in an array
20. Sorting 10 numbers stored in an array
21. Fibonacci series
22. Do while, loop while, while wend, Do until, loop until
23. Conversion of Celsius to Fahrenheit and vice versa
24. Swapping 2 numbers
25. Sum and Average of 10 numbers stored in a array
26. Creating an MDI application
27. Database connectivity using DAO
28. Database connectivity using RDO
29. Database connectivity using ADO
Friday, December 11, 2009
Write a Program in VB to sort 10 numbers using an Array
Private Sub Command1_Click()
Dim Number(10) As Integer
Dim i As Long
Dim j As Long
Dim Temp As Integer
For i = 1 To 10
Number(i) = InputBox("Enter any number")
Next
For i = 1 To 10
For j = i To 10
If Number(i) > Number(j) Then
Temp = Number(i)
Number(i) = Number(j)
Number(j) = Temp
End If
Next j
Next i
For i = 1 To 10
Print Number(i)
Next
End Sub
Wednesday, December 9, 2009
Write a program in VB to calculate average of 10 numbers using arrays
Dim n(10) As Integer
Dim sum As Long
Dim Avg As Single
sum = 0
For i = 1 To 10
n(i) = InputBox("Enter number")
Next
For i = 1 To 10
sum = sum + n(i)
Next
Print sum
Avg = sum / 10
Print Avg
End Sub