Sie sind auf Seite 1von 48

1. Write a program to print the series in ascending order and in descending order by using for loop?

Public Class Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim n As Integer, i As Integer n = Val(TextBox1.Text) For i = 1 To n Step 1 ListBox1.Items.Add(i) Next i End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim n As Integer, i As Integer n = Val(TextBox1.Text) For i = n To 1 Step -1 ListBox1.Items.Add(i) Next i End Sub End Class Output:

Q12) Create a project for book sales. Make text boxes for quantity, title and price with labels. Calculate total price, discount (15%) and discounted price. Make command buttons for calculate, clear and exit. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim quant As Integer Dim title As String Dim price As Decimal Dim tp As Decimal Dim disc As Decimal quant = TextBox1.Text title = (TextBox3.Text) price = TextBox2.Text tp = quant * price disc = (tp - ((15 * tp) / 100)) TextBox4.Text = tp TextBox5.Text = disc End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click End End Sub

Q13) Create a project for the local car rental agency that calculates rental charges. The agency charge $15 per day + $0.50 per km. use text boxes for customer name, address, city, state, zip code, beginning and ending audiometer reading and no. of days the car was used. Use labels to display the miles given and the total charges. Make command buttons for clear, exit and calculate. Public Class Form1 Dim br, er, miles, day As Integer Dim price As Decimal Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

GroupBox1.Hide() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click GroupBox1.Show() br = Val(TextBox6.Text) er = Val(TextBox7.Text) day = Val(TextBox8.Text) miles = er - br Label15.Text = miles price = (miles * day * 1.6) Label14.Text = price End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click GroupBox1.Hide() TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox7.Text = "" TextBox8.Text = "" End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Me.Close() End Sub End Class

Q14) Create a project that will input an employee salary. Calculate a gross salary, deduction and net salary. Each employee will receive a basic pay of $900 + sales commission of 6% of sales. After calculating the net paid calculate the budget amount of each category based on the % given. Bank pays $900 Commission 6% of sales Gross pay Basic pay + Commission Deduction 18% of gross pay Net pay Gross pay - deduction Budget:Housing 30% of net pay Food and clothing 15% of net pay Entertainment 50% of net pay

Miscellaneous 5% of net pay Use text boxes to input the employee name, amount of sales. Use labels to display the result and the calculation. Use calculates, clear and exit command buttons. Private Sub Command1_Click() Dim a, b As Integer Dim grosspay, deduction, netpay As Double a = Text1.Text b = Text2.Text grosspay = 900 + ((6 * b) / 100) deduction = (18 * grosspay) / 100 netpay = grosspay - deduction Label9.Caption = grosspay Label10.Caption = deduction Label11.Caption = netpay housing = (30 * netpay) / 100 food = (15 * netpay) / 100 enter = (50 * netpay) / 100 misc = (5 * netpay) / 100 budget = housing + food + enter + misc Label12.Caption = budget End Sub Private Sub Command2_Click() Text1.Text = "" Text2.Text = "" Label9.Caption = "" Label10.Caption = ""

Label11.Caption = "" Label12.Caption = "" End Sub Private Sub Command3_Click() End End Sub

Q20) A project to show working of both horizontal & vertical scroll bars on two different child forms of a MDI from. Description a) Let the user decide the height and width of a shape through scroll bars. b) Convert temp from Fahrenheit in to Celsius using vertical scroll bar. MDI FORM Option Explicit Private Sub MDIForm_Load() frmTemp.Show frmshape.Show End Sub

frmTemp Form Option Explicit Dim fahr As Single Private Sub Form_Load() Text1.Text = 32 Text2.Text = 0 End Sub Private Sub VScroll1_Change() Text2.Text = VScroll1.Value fahr = Val(Text2.Text) * 9 / 5 + 32 Text1.Text = Str(fahr) End Sub

frmShape Form Option Explicit Private Sub Form_Load() frmshape.Left = 9000 End Sub

Private Sub HScroll1_Change() Shape1.Width = HScroll1.Value End Sub

Private Sub VScroll1_Change() Shape1.Height = VScroll1.Value

End Sub

Q21) Create a project to display the images in a picture box using drive, directory & file List boxes. On the click of a command button with the caption next, user should be able to see next image in the same folder. Private Sub Command1_Click() 'Put image file name together and 'load image into image box Dim ImageName As String 'Check to see if at root directory If Right(File1.Path, 1) = "\" Then ImageName = File1.Path + File1.FileName Else ImageName = File1.Path + "\" + File1.FileName End If Label4.Caption = ImageName

MsgBox (ImageName) Picture1.Picture = LoadPicture(ImageName) End Sub

Private Sub Dir1_Change() 'If directory changes, update file path File1.Path = Dir1.Path End Sub Private Sub Drive1_Change() 'If drive changes, update directory Dir1.Path = Drive1.Drive End Sub

Q22) A project to show use of all types of library functions (string, numeric & date functions). Categorize various functions in the frames and display functions using option buttons.

Dim a As Variant Dim b As Variant Private Sub Form_Load() a = Text1.Text b = Text2.Text End Sub Private Sub Option1_Click() If Option1.Value = True Then MsgBox "the value is" & CInt(Val(Text1.Text) * Val(Text2.Text)) End If End Sub Private Sub Option2_Click() If Option2.Value = True Then Text1.Text = CDbl(Text1.Text) End If End Sub Private Sub Option3_Click() If Option3.Value = True Then MsgBox Rnd(Text1.Text) End If End Sub Private Sub Option4_Click() If Option4.Value = True Then MsgBox " " & LCase(Text2.Text)

End If End Sub Private Sub Option5_Click() If Option5.Value = True Then MsgBox UCase(Text2.Text) End If End Sub

Q23) A project to find total number of vowels, consonants, digits & other characters in a string. Private Sub Command1_Click() Dim iVowel As Integer Dim iCons As Integer Dim iNum As Integer Dim iSpace As Integer Dim iOther As Integer

Dim cnt As Integer Dim sChar As String For cnt = 1 To Len(Text1.Text) sChar = LCase(Mid(Text1.Text, cnt, 1)) Select Case sChar Case "a", "e", "i", "o", "u" ' iVowel = iVowel + 1 Case "a" To "z" iCons = iCons + 1 Case "0" To "9" iNum = iNum + 1 Case Else If sChar <> vbCr Then iOther = iOther + 1 End Select Next Text2.Text = iVowel Text3.Text = iCons Text4.Text = iNum Text5.Text = iOther End Sub

Q24) Write an age calculator to enter your date of birth and count the total number of age in seconds, age ,in days and age in years. Use appropriate controls for this application. Private Sub Command1_Click() Dim intYears As Integer Dim sec As Double intYears = Year(Now) - Year(Text1.Text) Label2.Caption = "in years= " & intYears If DateSerial(Year(Now), Month(Text1.Text), Day(Text1.Text)) > Now Then months = intYears * 12 Label3.Caption = "in months= " & months End If If DateSerial(Year(Now), Month(Text1.Text), Day(Text1.Text)) > Now Then days = intYears * 12 * 24

Label4.Caption = "in days= " & days End If If DateSerial(Year(Now), Month(Text1.Text), Day(Text1.Text)) > Now Then sec = intYears * 12 * 24 * 60 Label5.Caption = "in seconds= " & sec End If End Sub

Q25) Design a VB application that demonstrates the difference between call by value & call by reference mechanism. Private Sub Command1_Click() Dim z As Integer Dim h As Integer z = Val(Text3.Text) h = Val(Text2.Text) Call swap1(z, h)

Label6.Caption = z Label7.Caption = h End Sub

Private Sub Command2_Click() e = Val(Text3.Text) f = Val(Text2.Text) Call swap(e, f) Label4.Caption = e Label5.Caption = f End Sub

Sub swap(ByVal a As Integer, ByVal b As Integer) Dim t As Integer t=a a=b b=t End Sub Public Sub swap1(ByRef a As Integer, ByRef b As Integer) Dim t As Integer t=a a=b b=t End Sub

Q26) Create a list box, which contains names of all cinema halls of NCR. If you choose name of cinema hall, label display information regarding all movies running in the cinema halls. Private Sub Command1_Click() If MsgBox("Are You Sure You Want To Exit ?", vbYesNo) = vbYes Then End End If End Sub Private Sub List1_Click() Label2.Caption = "" Label3.Caption = "" Label4.Caption = "" MsgBox ("Processing ................. ") If List1. Label3.Caption = "Desi Boyz (U) 11.25, 14.45, 18.00, 21.15" ElseIf List1.ListIndex = 2 Then Label2.Caption = "SAAT KHOON MAAF(U/A) 10.45, 15.30, 20.00" Label3.Caption = "MISSION IMPOSSIBLE(U) 12.15, 15.45, 19.20" Label4.Caption = "Super Star (U) 11.50, 14.45, 18.30, 21.45" ElseIf List1.ListIndex = 3 Then

Label2.Caption = "Super Star (U) 12.00, 14.45, 18.20, 21.30" Label3.Caption = "KAHANI(U) 11.25, 14.45, 18.00, 21.15" ElseIf List1.ListIndex = 4 Then Label2.Caption = "SAAT KHOON MAAF(U/A) 10.45, 15.15, 19.30" Label3.Caption = "Desi Boyz (U) 11.25, 14.45, 18.00, 21.15" ElseIf List1.ListIndex = 5 Then Label2.Caption = "PAAN SINGH TOMAR (U/A) 11.00, 15.30, 19.45" Label3.Caption = "Desi Boyz (U) 11.25, 14.45, 18.00, 21.15" ElseIf List1.ListIndex = 6 Then Label2.Caption = "PAAN SINGH TOMAR (U/A) 10.45, 15.30, 20.00" Label3.Caption = "KAHANI(U) 11.25, 14.45, 18.00, 21.15" Label4.Caption = "Jumper (U) 11.55, 15.10, 18.20, 21.10" ElseIf List1.ListIndex = 7 Then Label2.Caption = "Mithya (U) 12.20, 15.00, 17.40, 20.00" Label3.Caption = "Desi Boyz (U) 11.25, 14.45, 18.00, 21.15" ElseIf List1.ListIndex = 8 Then Label2.Caption = "Jodhaa Akbar (U/A) 10.45, 15.30, 20.00" Label3.Caption = "Desi Boyz (U) 11.25, 14.45, 18.00, 21.15" ElseIf List1.ListIndex = 9 Then Label2.Caption = "Jodhaa Akbar (U/A) 11.00, 15.30, 19.45" Label3.Caption = "Desi Boyz (U) 11.25, 14.45, 18.00, 21.15" Label4.Caption = "Mithya (U) 12.20, 15.00, 17.40, 20.00" End If End Sub

Q27) Design an app in VB which makes use of Tabbed dialog control displaying your personal information on one tab and professional information on another. Use status bar messages for various controls.

Private Sub Command1_Click() MsgBox ("Data Stored Successfully") End Sub Private Sub Command2_Click() End End Sub Private Sub Form_Load() Frame1.Visible = False Command1.Visible = False Command2.Visible = False Text1.Visible = False Text2.Visible = False Text3.Visible = False Text4.Visible = False Text5.Visible = False Label1.Visible = False Label2.Visible = False Label3.Visible = False Label4.Visible = False Label5.Visible = False Label6.Visible = False Label7.Visible = False

Label8.Visible = False End Sub Private Sub TabStrip1_Click() i = TabStrip1.SelectedItem.Index Select Case i Case 1 Frame1.Visible = True Command1.Visible = True Command2.Visible = True Text1.Visible = True Text2.Visible = True Text3.Visible = True Text4.Visible = True Text5.Visible = True Label1.Visible = True Label2.Visible = True End Select End Sub

Q28) Write a program to check whether the given string is in upper case or lower case and also convert its case.(Without using library functions) Dim i As Integer, cap As Integer, sm As Integer, a As String, b As String Private Sub Command1_Click() For i = 1 To Len(Text1.Text) a = Mid(Text1.Text, i, 1) If Asc(Mid(Text1.Text, i, i)) >= 65 And Asc(Mid(Text1.Text, i, i)) <= 91 Then b = b &LCase(a) cap = cap + 1 ElseIfAsc(Mid(Text1.Text, i, 1)) >= 97 And Asc(Mid(Text1.Text, i, 1)) <= 122 Then b = b &UCase(a) sm = sm + 1 End If Next Label1.Caption = b End Sub

Private Sub Text1_Change() End Sub

Q29) Write a program to increase and decrease the size of the text by using horizontal and vertical bar? Private Sub HScroll1_Change() HScroll1.Min = 1 HScroll1.Max = 100 HScroll1.LargeChange = 10 HScroll1.SmallChange = 1 Label1.Font.Size = (HScroll1.Value) End Sub Private Sub VScroll1_Change() VScroll1.Min = 1 VScroll1.Max = 100 VScroll1.LargeChange = 10 VScroll1.SmallChange = 1 Label2.Font.Size = (VScroll1.Value) End Sub

Q30) Create a project to design a calculator by using control array?

Option Explicit Dim value1 As Double, value2 As Double, value As Double, flag As Integer Private Sub cmdClear_Click() txtInput.Text = 0 value1 = value2 = 0 End Sub Private Sub cmdDiv_Click() txtInput.Text = 0 If value = 0 Then value2 = value1 Else value2 = value End If Call Command1_Click(0) flag = 4 End Sub

Private Sub cmddot_Click() txtInput.Text = txtInput.Text & "." End Sub Private Sub cmdEqual_Click() If flag = 1 Then value = value2 + value1

txtInput.Text = value ElseIf flag = 2 Then value = value2 - value1 txtInput.Text = value ElseIf flag = 3 Then value = value2 * value1 txtInput.Text = value ElseIf flag = 4 Then If value1 = 0 Then txtInput.Text = "Cannot Divide by 0" Beep Else value = value2 / value1 txtInput.Text = value End If End If End Sub Private Sub cmdminus_Click() txtInput.Text = 0 If value = 0 Then value2 = value1 Else value2 = value End If Call Command1_Click(0)

flag = 2 End Sub Private Sub cmdmul_Click() txtInput.Text = 0 If value = 0 Then value2 = value1 Else value2 = value End If Call Command1_Click(0) flag = 3 End Sub

Private Sub cmdplus_Click() txtInput.Text = 0 If value = 0 Then value2 = value1 Else value2 = value End If Call Command1_Click(0) flag = 1 End Sub

Private Sub Command1_Click(Index As Integer)

If txtInput.Text = "Cannot Divide by 0" Then Beep ElseIf txtInput.Text = "0" Then txtInput.Text = Command1(Index).Caption Else txtInput.Text = txtInput.Text & Command1(Index).Caption End If value1 = Val(txtInput.Text) End Sub

Q31) Write a program to swap an image by using timer?

Private Sub Timer1_timer() If Image1.Visible = True Then

Image2.Visible = True Image1.Visible = False Else: Image2.Visible = True Image2.Visible = False Image1.Visible = True End If End Sub

Q32) Write a program designs the stopwatch by using timer control?

Private Sub cmdExit_Click() End End Sub Private Sub cmdReset_Click() If tmrStopWatch.Enabled = True Then

tmrStopWatch.Enabled = False lblTimeMS.Caption = "00:00" lblTimeMins.Caption = "00:" Else lblTimeMS.Caption = "00:00" lblTimeMins.Caption = "00:" End If End Sub

Private Sub cmdStopStart_Click() If tmrStopWatch.Enabled = False Then tmrStopWatch.Enabled = True Else tmrStopWatch.Enabled = False End If End Sub Private Sub Form_Load() tmrStopWatch.Enabled = False End Sub Private Sub tmrStopWatch_Timer() lblTimeMS.Caption = Format(Val(lblTimeMS.Caption) + 0.01, "fixed") If lblTimeMS.Caption = "60.00" Then lblTimeMins.Caption = lblTimeMins + 1 IblTimeMS.Caption = "00:00" End If

End Sub

Q33) Design a project for a MDI application, such that child1 contains no menu and child2 contains menu. With this demonstrate working of an MDI form?

Private Sub MDIForm_Load() Form7.Show

Form6.Show End Sub

Q34) Write a program, using recursive function to generate Fibonacci Series

Dim a As Variant Private Sub Command1_Click() Dim n As Integer n = Val(Text1.Text) a = Fib(n) End Sub Public Function Fib(num As Integer) As Integer Label3.Caption = "0" & " , " & "1"

If num <= 1 Then Fib = num Else Fib = Fib(num - 1) + Fib(num - 2) Label3.Caption = Label3.Caption & " , " & Fib End If End Function Private Sub command2_click() If MsgBox("Are You Sure You Want To Exit ?", vbYesNo) = vbYes Then End End If End Sub

Q35) Write a program, using recursive function to calculate Power of a number. Private Sub Command1_Click() Dim n As Integer Dim p As Integer Dim x As Integer n = Text1.Text p = Text2.Text x = power(n, p) Label4.Caption = "ANSWER IS :" & x End Sub

Public Function power(num As Integer, pow As Integer) As Integer If pow = 2 Then power = num * num Else power = num * power(num, pow - 1) E End Sub

Q36) Creating a tree view while Node1 is a parent node of Node2 and Node2 is a parent Node of Node3. Node1

Node2

Node3

Private Sub Form_Load() Dim Node1, Node2, Node3 As Node Set Node1 = TreeView1.Nodes.Add TreeView1.Nodes(1).Text = "Node 1" TreeView1.Nodes(1).Key = "Node1" Set Node2 = TreeView1.Nodes.Add("Node1", tvwChild, "Node 2") TreeView1.Nodes(2).Text = "Node 2" TreeView1.Nodes(2).Key = "Node2" Set Node3 = TreeView1.Nodes.Add("Node2", tvwChild, "Node 3") TreeView1.Nodes(3).Text = "Node 3 TreeView1.Nodes(3).Key = "Node 3"

End Sub

Q37) Write a program to design the search browser by using the text box, drive list box, Directory list box and file list box?

Dim X As Variant Dim i As Integer 'Dim i As Integer Private Sub Command1_Click() X=s z = Mid(Trim(Text1.Text), s, 1) Do While z <> "\" If s = q Then Exit Do End If

y=y+1 'MsgBox s s=s+1 z = Mid(Text1.Text, s, 1) Loop 's = s - 1 pt = Mid(Trim(Text1.Text), X, (y - 1)) MsgBox pt Loop End If 's = Text1.Text 'X = Left(s, 2) 'Drive1.Drive = X 'While i > 4 'X = Left(s, i) 'If X = "\" Then 'MsgBox "\" 'End 'Else 'y = y + 1 'End If 'Wend

'X = Left(s, y + 5)

'Print X End Sub Private Sub Dir1_Change() File1.Path = Dir1.Path Label1.Caption = Dir1.Path End Sub Private Sub Drive1_Change() Dir1.Path = Drive1.Drive Drive1.Drive = Label1.Caption End Sub Private Sub File1_Click() 'Picture1.Picture = LoadPicture(File1.Path + "\" + File1.FileName) 'Label1.Caption = File1.Path + "\" + File1.FileName End Sub

Q38) A project to imitate a mini Notepad using Rich text box. Make use of Show open, show save, Show colour & show font dialog boxes in your notepad. Also set current Values of the dialog box?

Dim fn As String Dim ul As Boolean Dim st As Boolean Dim m As Integer Private Sub Form_Load() m=0 ul = False st = False End Sub

Private Sub Form_Resize() If WindowState = 1 Then Exit Sub End If Text1.Width = ScaleWidth Text1.Height = ScaleHeight End Sub

Private Sub Form_Unload(Cancel As Integer) mnufileexit_Click End Sub

Private Sub mnufilenew_Click()

If Text1 <> "" Then msg = "The Text in the file has changed." & vbCrLf & "Do u wish to save the changes?" res = MsgBox(msg, vbYesNoCancel, "Save File?") Select Case res Case vbYes If fn = "" Then mnufilesaveas_Click Else mnufilesave_Click End If Text1 = "" Form1.Caption = "Untitled - Notepad" Case vbNo Text1 = "" Form1.Caption = "Untitled - Notepad" Case vbCancel End Select End If End Sub

Private Sub mnufileopen_Click() file.Filter = "Text (*.txt)|*.txt|All Files (*.*)|*.*" file.InitDir = "c:\" file.ShowOpen If file.FileName = "" Then

Exit Sub End If fn = file.FileName Open fn For Input As #1 Text1.Text = StrConv(InputB(LOF(1), 1), vbUnicode) Close #1 Form1.Caption = file.FileTitle & " - Notepad" End Sub

Private Sub mnufilesave_Click() On Error GoTo errhandler file.CancelError = True file.Flags = cdlOFNHideReadOnly + cdlOFNOverwritePrompt + cdlOFNPathMustExist file.Filter = "Text (*.txt)|*.txt|All Files (*.*)|*.*" If fn = "" Then file.FileName = "" file.ShowSave fn = file.FileName End If Open fn For Output As #1 Print #1, Text1.Text Close #1 Form1.Caption = file.FileTitle & " - Notepad" errhandler: Select Case Err

Case 32755 ' Dialog Cancelled End Select & " - Notepad" errhandler: Select Case Err Case 32755 ' Dialog Cancelled End Select End Sub ?") Select Case res Case vbYes If fn = "" Then mnufilesaveas_Click Else mnufilesave_Click End If End Case vbNo End Case vbCancel End Select Else End End If End Sub

Private Sub mnueditcut_Click() If m = 1 Then Clipboard.SetText Text1.Text Text1.Text = "" Else Clipboard.SetText Text1.SelText Text1.SelText = "" End If End Sub

Private Sub mnueditcopy_Click() If m = 1 Then Clipboard.SetText Text1.Text Else Clipboard.SetText Text1.SelText End If End Sub

Private Sub mnueditpaste_Click() Text1.SelText = Clipboard.GetText End Sub

Private Sub mnufont_Click()

On Error GoTo errhandler file.Flags = cdlCFScreenFonts Or cdlCFPrinterFonts file.ShowFont Text1.FontName = file.FontName Text1.FontBold = file.FontBold Text1.FontItalic = file.FontItalic Text1.FontSize = file.FontSize errhandler: Select Case Err Case 32755 ' Dialog Cancelled End Select End Sub

Private Sub mnueditbc_Click() On Error GoTo errhandler file.CancelError = True file.ShowColor Text1.BackColor = file.Color errhandler: Select Case Err Case 32755 ' Dialog Cancelled End Select End Sub

Private Sub mnueditfc_Click()

On Error GoTo errhandler file.CancelError = True file.ShowColor Text1.ForeColor = file.Color errhandler: Select Case Err Case 32755 ' Dialog Cancelled End Select End Sub

Private Sub mnuabt_Click() MsgBox ("THIS IS NOTEPAD") End Sub Private Sub mnufontst_Click() st = Not st Text1.FontStrikethru = st End Sub Private Sub mnufontul_Click() ul = Not ul Text1.FontUnderline = ul End Sub

Private Sub selectall_Click() m=1

End Sub

Q39) Design an application in visual basic which makes use of the following controls:: Image List, Toolbars & Progress Bar & status Bar. Private Sub Combo1_Click() Text1.Font = Combo1.Text End Sub Private Sub Form_Load() Timer1.Enabled = False End Sub Private Sub Timer1_Timer() If Form2.BackColor = vbRed Or Form2.BackColor = vbGreen Then Form2.BackColor = vbYellow ElseIf Form2.BackColor = vbYellow Then Form2.BackColor = vbRed ElseIf Form2.BackColor = vbRed Then Form2.BackColor = vbGreen

End If End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) If Button.Index = 1 Then Text1.FontSize = Text1.FontSize - 1 ElseIf Button.Index = 2 Then Text1.FontSize = Text1.FontSize + 2 End If If Button.Index = 3 Then Form2.BackColor = vbRed Timer1.Enabled = True ElseIf Button.Index = 5 Then Timer1.Enabled = False Form2.BackColor = vbBlue ElseIf Button.Index = 6 Then Form2.BackColor = vbBlack ElseIf Button.Index = 7 Then Form2.BackColor = vbWhite ElseIf Button.Index = 8 Then Text1.Font = CommonDialog1.FontName End If End Sub

Q 42) Creating a tree view while Node1 is a parent node of Node2 and Node2 is a parent Node of Node3. Node1

Node2

Node3

Private Sub Form_Load() Dim Node1, Node2, Node3 As Node Set Node1 = TreeView1.Nodes.Add TreeView1.Nodes(1).Text = "Node 1" TreeView1.Nodes(1).Key = "Node1" TreeView1.Nodes(1).Image = 1 Set Node2 = TreeView1.Nodes.Add("Node1", tvwChild, "Node 2")

TreeView1.Nodes(2).Text = "Node 2" TreeView1.Nodes(2).Key = "Node2" TreeView1.Nodes(2).Image = "two" Set Node3 = TreeView1.Nodes.Add("Node2", tvwChild, "Node 3") TreeView1.Nodes(3).Text = "Node 3" TreeView1.Nodes(3).Key = "Node 3" TreeView1.Nodes(3).Image = "three" End Sub

Das könnte Ihnen auch gefallen