Hamid

   
 
  CS-65
Course Code : CS-65
Course Title : Windows Programming
Assignment Number : BCA (4)-65/Assignment/ 2008
Maximum Marks : 25
Last Date of Submission : 30th April, 2008/30th October, 2008



Question : 1 Explain Visual Basic development environment. Also discuss the basic programme structure in Visual Basic.

Ans :
The visual basic IDE has three distinct states :
            - Design
            - Run
            - and Debug.

      The current state aapears in visual basics title bar. The IDE is composed of these parts :-
            - The menu bar
            - The tool bar
            - The project Explorer
            - The properties Window
            - The form layout Window
            - The toolbox.




Selecting IDE colors, fonts and font size.


      Basic Programming structure is much similar to other programming languages. Visual basic language supports a large number of programming constructs and elements and that languages is the foundation on which we will build our projects.

      How does Visual basic code look ?

Private sub command1_click()
Dim Str As Sting
Dim x,y,z As Integer
x=10
y=20
z=x+y
MsgBox "The Sum is "&x
End Sub

Private Sub Command1_Click()
Dim x,y,z As Integer
x=10
u=20
z=30
If x>y and x>z Then
MsgBox "x is greatest "
ElseIf y>x and y>z
MsgBox "y is greates "
Else
MsgBox "z is greatest"
End If
"declaring an array in VB
dim arr(5) an integer
End sub

      In the above example we shown how to declare a variable by using dim statement and intializing the value and print the messages and the value stored in vasriable by using MsgBox() function also shown the system of it conditionjal statement,. This is the basic programme structure in visual basic.



Question : 2 Explain the need of built-in functions in Visual Basic. List out the various built in functions that are available in the latest version.

Ans.
Functions/Procedures/Methods:- functions are collection of programming statement written under a block and execute as a single unit.

two types of function we have in VB.

1. System Defined:- system defined function are also known as premitive function which are already defined and exist in VB liabrary. we have to use them as per our

requirment and convinient and they are as follows:-

i). Conversion functions:- like cint(),val(),Asc(),chr(),cbool(),cdate() and so on.

ii). Date Functions :- now,time,date,datediff,math,day

iii). string functions:- strreverse,strcomp,instr,mid and so on.

these system defined functions are very use full for us in our programe we donot need to develop the logic again and again to that work.

2. User Defined:-which are defined by us .

i). sub procedure

ii). function procedure

iii). property procedure

Examples:-

 

Print Asc("a")

Dim i As Integer

i = Asc("a")

Print i

 

 

Print Chr(97)

 

 

Dim str1 As String

str1 = "10"

Dim no As Integer

no = Val(str1)

Print no

str1 = str(no)

Print str1

 

Dim sdate As String

sdate = "2 january, 1994"

Dim dt As Date

dt = CDate(sdate)

Print dt

 

Private Sub Command9_Click()

'Removing spaces in the string

 

Dim str As String

str = "         Bye          "

str = LTrim(str)

Print str

 

Print str

str = RTrim(str)

Print str

str = Trim(str)

Print str

 

 

 

 

'Comparing string

Dim str1 As String

Dim str2 As String

str1 = "HELLO"

str2 = "hello"

 

 'strcomp(<str1>,<str2>,<compare type>)

 

' -1 return str1 < str2

'  0 return str1 = str2

'  1 return str1 > str2

 

'<compare type>

    '0 for binary

    '1 for textual

   

Dim res As Integer

res = StrComp(str1, str2, 1)

Print res

res = StrComp(str1, str2, 0)

Print res

res = StrComp(str2, str1, 0)

Print res

 

 

'Reversing Strings

Dim strrev As String

strrev = "hello how are you"

strrev = StrReverse(strrev)

Print strrev

 

 

'Searching for a string within a string

 

 

Dim searched As String

Dim found As String

Dim startsearch As Integer

Dim comparetype As Integer

 

searched = "This is the good book"

found = "good"

startsearch = 1

comparetype = 1

 

Dim resu As Integer

resu = InStr(startsearch, searched, found, comparetype)

Print "The position=>" & resu

 

found = "good"

comparetype = 0

resu = InStr(startsearch, searched, found, comparetype)

Print resu

 

resu = InStr(searched, found)

Print resu

 

'0 for not found

'position no for found

 

 

 

 

'replace a part of the string

 

Dim strString As String

strString = "thank you"

Mid(strString, 1, 5) = "Oh My"

Print strString

Mid(strString, 7) = "God" '

Print strString

 

 

 

 

 

'changing the case

 

Dim ustr As String

Dim lstr As String

ustr = "HELLO"

lstr = "bye"

ustr = LCase(ustr)

'Print ustr

lstr = UCase(lstr)

'Print lstr

End Sub





Question : 3 Analyze the difference between Local, Module level, and Global Variable. Also explain how ActiveX DLLS are created.

Ans:- Local vaiables are local for the block in which it is defined means if we declare a variable in any function or procedure that variable can be used with that function or procedure block. It means that is local for that procedure or function. Module level variables are public and can be accessed any where with in the module block or that code which contains the object of the module. By making we can use the module data members. But if we make a variable global in a program, means if we declare the variable at the top of all the code that become the global variable for that perticular module or program and we can use that variable in any function or code of the program with out adding any refference. And if any function or code of the program with out adding any refference. And if any code will change the value of global variable that will reflect though out the complete program.

for example :-
in a for module

'global variable for whole program
dim ctr as integer
public sub Form_Load()
'local variable for the form_load procedure
dim x as integer
end sub

Creating Active X DLL's :-
      An activeX DLL is a code that runs in the same process as the client application. So it runs in the same address space as the client application that is using the componenet.
      Any componenets you create to work with Microsoft Transaction Server must be ActiveX DLL componenets. Any other components you develop for use on the same machine as the client application can also be ActiveX DLL componenets. This is normally the preferred choice because it is easier to test (by adding another project using the new VB5 project group feature) and has better performance.



Question : 4 Discuss what constitutes proper code writing conventions in Visual Basic. Also write code in Visual Basic to find square root of a given number.

Ans:- Microsoft has set up a number of conventions for programming visual basic including naming conventions. These conventions are not necessary if you program alone, but they can still be helpful.
1. Variable Scope Prefix :- if you have a global variable named ErrorCount, you can use the g Prifix to indicate that, that variable is a global variable.
2. Variable Pefix : - Variable names should be prefixed to indicate their data type.
example :- Boolean=bln and double=dbl
3. Control Prefix :- which control we are using in our project we have to use the control prefix accordingle like
for textbox, we use txt, label=lbl, richtextbox=rtf, combobox=cbo, listbox=lbx and so on.
4. Code commenting Conventions :- We should add a new comment when you declare a new and important variable or project.
For example,
1. Purpose :- what the purpose does
2. assumptions
3. effects
4. inputs
5. returns.

Program to find square root of any given number
Private Sub Command1_Click()
Dim x As Integer
x=InputBox("enter any number")
MsgBox Sqr(x)
End Sub



Question : 5 Explain the chart control and grid control in Visual Basic.

Ans :-
Chart control :-
Chart Control is the most use full and power full feature of vb 6.0 to display and presenet the data or information.
Inspite of displaying in text box we can display the data in the graphical and attractive format by using different types of chart like pie chart, 3d and 2d bar chart or line chart etc.

To add chart in vb6.0 follow the following steps.
1. Select the project/Component menu item.
2. Select the controls tab in the components box that opens.
3. Selent the microsoft chart control entry in the components box, and click on ok to close the components box.
4. Draw a new chart control on your form.
To select the type of chart you want, you set the chart controls chart type property
VtChChartType3dBar-3d bar chart
VtChChartType2dBar-2d bar chart
VtChChartType3dLine-3d Line chart
and so on.

Grid Control :-
Grid control in vb is a very most use full complex data bound control to display the data from multiple table at one time.
For that purpose we have the flex grid control vb6.0.
1. Select the project/Component menu items.
2. Click the controls tab in the components dialog box.
3. Select the MS Flex Grid control entry in the components dialog box.
4. Close the components dialog box by clicking on OK. This displays the Flex Grid Control tool.
5. Add a flex grid Control to your form in the usual way to visual basic controls, using the Flex Grid Control tool.
6. Set the flex grid's Rows and cols properties to the number of rows and cols you want in your flex grid. You can also customize your flex grid by setting such propertied as border styles, forcolor, backcolor.



Question : 6 Create a form where the user can enter their name into text box and have the name as output into a label in a different font and color.

Ans:-
Fig:-1



Private Sub Command1_Click()
Label2.ForeColor=vbRed
Label2.Font=Bold
Label2.FontName="Comic Sans MS"
Label2.FontSize=24
Label2.Caption=Text1.Text
End Sub

Fig:-2






Question : 7 Build a form with two drop down lists (combo boxes type 0), one for country name and the other for the name of the President/Head of the countries. When this form is loaded fill the lists from the arrays. If the user pulls down one of the lists and clicks on a country the name of corresponding country President/Head is displayed in the text box of the other list.

Ans:-
Fig :- 1





Private Sub Form_Load()
Dim country(5) As string
Dim i As Integer
country(0)="__Select__"
country(1)="India"
country(2)="Australia"
country(3)="America"
country(4)="Rusia"
country(5)="Japan"
Comb1.Additem(CStr(country(i)))
Next
Combo1.ListIndex = 0

Dim prdt(5) As String
prdt(0)="__Select__"
prdt(1)="Ram"
prdt(2)="Shyam"
prdt(3)="Kumar"
prdt(4)="AtalBihari"
prdt(5)="hamid raza"

For i=0 To UBound(prdt)
Combo2.ListIndex=0
End sub.



Question : 8 Create an application with 2 small picture boxes and one large picture box. Each of the small picture box has a radia button. When a radio button is selected, the corresponding image for the picture box gets placed in the large picture box and a level is generated with the caption of the selected picture just below the large picture box.

Ans:-
Fig :- 1




Private Sub Form_Load()
Picture1.Picture=LoadPicture("C:Document and SettingHamidDesktopViual BasicAssignmentsVB31.jpg")
Picture2.Picture=LoadPicture("C:Document and SettingHamidDesktopViual BasicAssignmentsVB33.jpg")
Label1.Visible=False
End Sub

Private Sub Option1_Click()
If Option1.Value=True Then
Picture3.Picture=Picture1.Picture
Label1.Visible="Picture1"
Label1.Visible=True
End If
End Sub

Private Sub Option2_Click()
If Option2.Value = True Then
Picture3.Picture=Picture2.Picture
Label1.Caption="picture 2"
Label1.Visible=True
End If
End Sub



Question : 9 Generate a list (use an array of appropriate dimensions) including name, given name and course and address of 10 students consecutively numbered. Generate a program, which prints all information of the students on request of a number (1 to 10).

Ans:-
Private Sub Command1_Click()
Dim i,j As integer
Dim arr(10,3) As string
For i=0 to 9
For j=0 to 2
If j=0 Then
arr(j,j)=InputBox("enter the name")
End If
If j=2 Then
arr(i,j)=InputBox("Enter the city")
End if
Next
Next

Dim sno As Integer
sno=InputBox("enter whichs student details you want to see")
Print "The name is " &arr(sno,0)
Print "The course is" &arr(sno,1)
Print "The city is " & arr(sno,2)

End sub



Question : 10 Create a Form with a picture box. Find some interesting pictures. Use a timer control to cycle the picture every 2 seconds.The form should close when the picture is clicked.

Ans:-
Fig :-1




Private Sub Timer1_Timer()
If Timer1.Interver=2000 Then
Picture1.Picture=LoadPicture("C:Document and SettingHamidDesktopViual BasicAssignmentsVB31.jpg")
End if
Timer1.Interval=4000
If Timer1.Interval=4000 Then
Picture1.Picture=LoadPicture("C:Document and SettingHamidDesktopViual BasicAssignmentsVB32.jpg")
End If
Timer1.Interval=6000
If Timer1.Interval=6000 Then
Picture1.Picture=LoadPicture("C:Document and SettingHamidDesktopViual BasicAssignmentsVB33.jpg")
End If
Timer1.Interval=8000
If Timer1.Interval=8000 Then
Picture1.Picture=LoadPicture("C:Document and SettingHamidDesktopViual BasicAssignmentsVB32.jpg")
End If
End sub


Login
 
Username:
Password:
Donate
 
You can help this website
by donate or
you can click an
advertisement.

IGNOU Students
 
Sample Synopsis

Time Table BCA 2009
Projects (Vb n ASPnet) : Download
Synopsis Form

Training Letter

Guide Remuneration Form

Certificates of Originality

Java KeyWords - PDF

Java KeyWords - Wikipedia


Click Here / Click Here

Edit Plus (Use it as Java editor) Download

How to configure EditPlus to compile JAVA codes click here


Advertisement
 
PC Games (Full, Rip, Compressed)
 
 
© 2007 - 2009 HamidRaza - Today, there have been 49 visitors (165 hits) on this page!
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free