You are on page 1of 61

II.

Aplicatii

1. Analiza text. Sa se preia un text dintr-un fisier, de la tastatura sau prin copiere.
Actionarea unui buton sa analizeze textul afisand pe rand cuvintele, propozitiile,
frazele si caracterele si numarul de aparitii ale acestora.

Varianta 1. (nu salveaza baza de date)

Private Sub Command1_Click()


Unload Me
End
End Sub

Private Sub Command2_Click()


On Error Resume Next
Dim cuv() As String
Dim tot() As Long
Dim i As Long, j As Long

27
If Len(Text1) <> 0 Then

cuv = Split(Trim(Text1), " ", , vbTextCompare)


Form3.Text1.Text = "Cuvinte gasite: " & UBound(cuv) + 1 & vbCrLf

ReDim tot(UBound(cuv))
' Form3.Text1.Text = vbNewLine
'nr aparitii
For i = 0 To UBound(cuv)
For j = 0 To UBound(cuv)
If Trim(cuv(i)) = Trim(cuv(j)) Then tot(i) = tot(i) + 1
Next
Next
For i = 0 To UBound(cuv)
For j = i + 1 To UBound(cuv)
If Trim(cuv(i)) = Trim(cuv(j)) Then cuv(i) = ""
Next
Next
' afisare
For i = 0 To UBound(cuv)
If cuv(i) <> "" Then Form3.Text1.Text = Form3.Text1.Text & "Cuvant: " &
Chr(34) & cuv(i) & Chr(34) & " nr aparitii: " & tot(i) & vbCrLf
Next
Form3.Text1.Text = Form3.Text1.Text + "----------------------"
'afisare propozitii (succesiune de cuvinte urmate de .)
Dim prop() As String
prop = Split(Text1, ".", , vbTextCompare)
Form3.Text1.Text = Form3.Text1.Text & "Propozitii gasite: " & UBound(prop)
& vbCrLf
ReDim tot(UBound(prop))
' total aparitii
For i = 0 To UBound(prop)
For j = 0 To UBound(prop)
If Trim(prop(i)) = Trim(prop(j)) Then tot(i) = tot(i) + 1
Next
Next
For i = 0 To UBound(prop)
For j = i + 1 To UBound(prop)
If Trim(prop(i)) = Trim(prop(j)) Then prop(i) = ""
Next
Next
' afisare
For i = 0 To UBound(prop)
If prop(i) <> "" Then Form3.Text1.Text = Form3.Text1.Text & "Propozitie: " &
Chr(34) & prop(i) & Chr(34) & " nr aparitii: " & tot(i) & vbCrLf

28
Next
Form3.Text1.Text = Form3.Text1.Text + "-------------------------"
'afisare frazele (succesiune de cuvinte urmate de . si ,)
Dim fraz() As String
fraz = Split(Text1, ".", , vbTextCompare)
fraz = Split(Text1, ",", , vbTextCompare)
Form3.Text1.Text = Form3.Text1.Text & "frazele gasite: " & UBound(fraz) + 1
& vbCrLf
ReDim tot(UBound(fraz))
' total aparitii
For i = 0 To UBound(fraz)
For j = 0 To UBound(fraz)
If Trim(fraz(i)) = Trim(fraz(j)) Then tot(i) = tot(i) + 1
Next
Next
For i = 0 To UBound(fraz)
For j = i + 1 To UBound(fraz)
If Trim(fraz(i)) = Trim(fraz(j)) Then fraz(i) = ""
Next
Next
' afisare
For i = 0 To UBound(fraz)
If fraz(i) <> "" Then Form3.Text1.Text = Form3.Text1.Text & "frazele: " &
Chr(34) & fraz(i) & Chr(34) & " nr aparitii: " & tot(i) & vbCrLf
Next
Form3.Text1.Text = Form3.Text1.Text + "------------------------"
Dim lit() As String
ReDim lit(Len(Text1))
Form3.Text1.Text = Form3.Text1.Text & "Litere gasite: " & UBound(lit) &
vbCrLf
ReDim tot(UBound(lit))
For i = 0 To UBound(lit)
lit(i) = Mid(Text1, i + 1, 1)
Next
For i = 0 To UBound(lit)
For j = 0 To UBound(lit)
If lit(i) = lit(j) Then tot(i) = tot(i) + 1
Next
Next
For i = 0 To UBound(lit)
For j = i + 1 To UBound(lit)
If lit(i) = lit(j) Then lit(i) = ""
Next
Next
' afisare
For i = 0 To UBound(lit)

29
If lit(i) <> "" Then Form3.Text1.Text = Form3.Text1.Text & "Litera: " &
Chr(34) & lit(i) & Chr(34) & " nr aparitii: " & tot(i) & vbCrLf
Next

Else
Form3.Text1 = "ERROR: TEXT SURSA INEXISTENT"
End If
Form3.Show 1, Me
End Sub

Private Sub Command3_Click()


On Error Resume Next

Dim fileData As String


CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
fileData = Input(LOF(1), 1)
Close #1
Text1.Text = fileData
End Sub

Private Sub Form_Load()


CommonDialog1.Filter = "Text (*.txt)|*.txt|All files (*.*)|*.*"
End Sub
Varianta 2 (salveaza baza de date in fisierul exemplu.txt)

30
Private Sub Command1_Click()
Text1.Text = Text1.Text & Text2.Text
Text2.Text = ""
'numarare propozitii
prop = ""
For i = 1 To Len(Text1.Text)
If Mid(Text1.Text, i, 1) = "." Then
prop = prop & "."
este = 0
For j = 0 To List1.ListCount - 1
If List1.List(j) = prop Then
este = 1
Else
End If
Next j
If este = 0 Then
List1.AddItem (prop)
Else
End If
prop = ""
Else
prop = prop & Mid(Text1.Text, i, 1)
End If
Next i
For j = 0 To List1.ListCount - 1
List4.List(j) = 0
For i = 1 To Len(Text1.Text) - Len(List1.List(j)) + 1
If List1.List(j) = Mid(Text1.Text, i, Len(List1.List(j))) Then
List4.List(j) = List4.List(j) + 1
Else
End If
Next i
Next j
'numarare cuvinte
cuv = ""
For i = 1 To Len(Text1.Text)
If Mid(Text1.Text, i, 1) = " " Or Mid(Text1.Text, i, 1) = "." Then
este = 0
For j = 0 To List2.ListCount - 1
If List2.List(j) = cuv Then
este = 1
Else
End If
Next j
If este = 0 Then
List2.AddItem (cuv)

31
Else
End If
cuv = ""
Else
cuv = cuv & Mid(Text1.Text, i, 1)
End If
Next i
For j = 0 To List2.ListCount - 1
List5.List(j) = 0
For i = 1 To Len(Text1.Text) - Len(List2.List(j)) + 1
If List2.List(j) = Mid(Text1.Text, i, Len(List2.List(j))) Then
List5.List(j) = List5.List(j) + 1
Else
End If
Next i
Next j
'numarare caractere
For i = 1 To Len(Text1.Text)
este = 0
For j = 0 To List3.ListCount - 1
If List3.List(j) = Mid(Text1.Text, i, 1) Then
este = 1
Else
End If
Next j
If este = 0 Then
List3.AddItem (Mid(Text1.Text, i, 1))
Else
End If
Next i
For j = 0 To List3.ListCount - 1
List6.List(j) = 0
For i = 1 To Len(Text1.Text)
If List3.List(j) = Mid(Text1.Text, i, Len(List3.List(j))) Then
List6.List(j) = List6.List(j) + 1
Else
End If
Next i
Next j

End Sub

Private Sub Command2_Click()


Label7.Visible = Not (Label7.Visible)
End Sub
Private Sub Command3_Click()

32
Open "exemplu.txt" For Output As #1
Print #1, Text1.Text
Close #1
End
End Sub
Private Sub Form_Load()
Open "exemplu.txt" For Input As #1
Line Input #1, a
Close #1
Text1.Text = a
'numarare propozitii
prop = ""
For i = 1 To Len(Text1.Text)
If Mid(Text1.Text, i, 1) = "." Then
prop = prop & "."
este = 0
For j = 0 To List1.ListCount - 1
If List1.List(j) = prop Then
este = 1
Else
End If
Next j
If este = 0 Then
List1.AddItem (prop)
Else
End If
prop = ""
Else
prop = prop & Mid(Text1.Text, i, 1)
End If
Next i
For j = 0 To List1.ListCount - 1
List4.List(j) = 0
For i = 1 To Len(Text1.Text) - Len(List1.List(j)) + 1
If List1.List(j) = Mid(Text1.Text, i, Len(List1.List(j))) Then
List4.List(j) = List4.List(j) + 1
Else
End If
Next i
Next j
'numarare cuvinte
cuv = ""
For i = 1 To Len(Text1.Text)
If Mid(Text1.Text, i, 1) = " " Or Mid(Text1.Text, i, 1) = "." Then
este = 0
For j = 0 To List2.ListCount - 1

33
If List2.List(j) = cuv Then
este = 1
Else
End If
Next j
If este = 0 Then
List2.AddItem (cuv)
Else
End If
cuv = ""
Else
cuv = cuv & Mid(Text1.Text, i, 1)
End If
Next i
For j = 0 To List2.ListCount - 1
List5.List(j) = 0
For i = 1 To Len(Text1.Text) - Len(List2.List(j)) + 1
If List2.List(j) = Mid(Text1.Text, i, Len(List2.List(j))) Then
List5.List(j) = List5.List(j) + 1
Else
End If
Next i
Next j
'numarare caractere
For i = 1 To Len(Text1.Text)
este = 0
For j = 0 To List3.ListCount - 1
If List3.List(j) = Mid(Text1.Text, i, 1) Then
este = 1
Else
End If
Next j
If este = 0 Then
List3.AddItem (Mid(Text1.Text, i, 1))
Else
End If
Next i
For j = 0 To List3.ListCount - 1
List6.List(j) = 0
For i = 1 To Len(Text1.Text)
If List3.List(j) = Mid(Text1.Text, i, Len(List3.List(j))) Then
List6.List(j) = List6.List(j) + 1
Else
End If
Next i
Next j

34
End Sub

Private Sub List1_Click()


Text3.Text = List4.List(List1.ListIndex)
End Sub
Private Sub List2_Click()
Text4.Text = List5.List(List2.ListIndex)
End Sub
Private Sub List3_Click()
Text5.Text = List6.List(List3.ListIndex)
End Sub

2. Asigurari medicale (problema 11 , pagina 246)

Form1:
Dim nume As String
Dim varsta As Integer
Dim durata_contract As Integer
Dim rata As Double
Dim suma_acumulata As Double
Dim coef_sanatate As Double
Dim prima As Double

Private Sub command1_click()

Form1.Hide

35
Form2.Show
Form2.Command1 = True

End Sub

Private Sub Command2_Click()


Text1.Text = Empty
Text2.Text = Empty
Text3.Text = Empty
Text4.Text = Empty
Combo1.Text = "Sanatos"

End Sub

Private Sub Command3_Click()


End
End Sub

Form2:
Dim sir As String
Dim suma_acumulata As Double
Dim rata_lunara As Double
Dim coef_sanatate As Double
Dim coef_varsta As Double
Dim prima As Double

Private Sub initializare_tabel()


tabel.Row = 0
tabel.Cols = 7
tabel.Col = 0
tabel.ColWidth(0) = 2500
tabel.CellFontBold = True
tabel.CellFontUnderline = True
tabel.CellAlignment = 4
tabel.Text = "Nume"
tabel.Col = 1
tabel.ColWidth(1) = 1000
tabel.CellFontBold = True
tabel.CellFontUnderline = True
tabel.CellAlignment = 4
tabel.Text = "Varsta"
tabel.Col = 2
tabel.ColWidth(2) = 1500

36
tabel.CellFontBold = True
tabel.CellFontUnderline = True
tabel.CellAlignment = 4
tabel.Text = "Sanatate"
tabel.Col = 3
tabel.ColWidth(3) = 1500
tabel.CellFontBold = True
tabel.CellFontUnderline = True
tabel.CellAlignment = 4
tabel.Text = "Durata contract"
tabel.Col = 4
tabel.ColWidth(4) = 1500
tabel.CellFontBold = True
tabel.CellFontUnderline = True
tabel.CellAlignment = 4
tabel.Text = "Rata lunara"
tabel.Col = 5
tabel.ColWidth(5) = 1500
tabel.CellFontBold = True
tabel.CellFontUnderline = True
tabel.CellAlignment = 4
tabel.Text = "Suma acumulata"
tabel.Col = 6
tabel.ColWidth(6) = 1700
tabel.CellFontBold = True
tabel.CellFontUnderline = True
tabel.CellAlignment = 4
tabel.Text = "Prima"
tabel.Rows = tabel.Rows + 1
tabel.Row = tabel.Row + 1

End Sub
Private Sub command1_click()
If (Form1.Text1.Text = "") Or (Form1.Text2.Text = "") Or (Form1.Text3.Text = "")
Or (Form1.Text4.Text = "") Then
MsgBox "Va rugam sa completati toate campurile cu datele asiguratului", vbCritical
Else

suma_acumulata = Form1.Text4.Text * Form1.Text3.Text

If Val(Form1.Text2.Text) > 0 And Val(Form1.Text2.Text) <= 20 Then


coef_varsta = 0.5
Else
If Val(Form1.Text2.Text) > 20 And Val(Form1.Text2.Text) <= 40 Then
coef_varsta = 0
Else

37
If Val(Form1.Text2.Text) > 40 Then
coef_varsta = -0.5
End If
End If
End If

If Form1.Combo1.Text = "Bolnavicios" Then


coef_sanatate = 0.5
End If
If Form1.Combo1.Text = "Sanatos" Then
coef_sanatate = 1
End If
If Form1.Combo1.Text = "Foarte sanatos" Then
coef_sanatate = 1.5
End If

rata_lunara = (Form1.Text4.Text) / 12

prima = (coef_sanatate + coef_varsta) * suma_acumulata

tabel.Col = 0
tabel.CellFontBold = False
tabel.CellFontUnderline = False
tabel.CellAlignment = 4
tabel.Text = Form1.Text1.Text
tabel.Col = 1
tabel.ColWidth(1) = 1000
tabel.CellFontBold = False
tabel.CellFontUnderline = False
tabel.CellAlignment = 4
tabel.Text = Form1.Text2.Text
tabel.Col = 2
tabel.ColWidth(2) = 1500
tabel.CellFontBold = False
tabel.CellFontUnderline = False
tabel.CellAlignment = 4
tabel.Text = Form1.Combo1.Text
tabel.Col = 3
tabel.ColWidth(3) = 1500
tabel.CellFontBold = False
tabel.CellFontUnderline = False
tabel.CellAlignment = 4
tabel.Text = Form1.Text3.Text
tabel.Col = 4
tabel.ColWidth(4) = 1500
tabel.CellFontBold = False

38
tabel.CellFontUnderline = False
tabel.CellAlignment = 4
tabel.Text = rata_lunara
tabel.Col = 5
tabel.ColWidth(5) = 1500
tabel.CellFontBold = False
tabel.CellFontUnderline = False
tabel.CellAlignment = 4
tabel.Text = suma_acumulata
tabel.Col = 6
tabel.ColWidth(6) = 1500
tabel.CellFontBold = False
tabel.CellFontUnderline = False
tabel.CellAlignment = 4
tabel.Text = prima
tabel.Rows = tabel.Rows + 1
tabel.Row = tabel.Row + 1

End If
End Sub

Private Sub Command2_Click()


End
End Sub

Private Sub Command3_Click()


Form2.Hide
Form1.Text1.Text = Empty
Form1.Text2.Text = Empty
Form1.Text3.Text = Empty
Form1.Text4.Text = Empty
Form1.Combo1.Text = "Sanatos"
Form1.Show

End Sub

Private Sub Data1_Validate(Action As Integer, Save As Integer)

End Sub

Private Sub Form_Load()


initializare_tabel

End Sub

39
3. Agenda (problema 9 pagina 246)

Form1:
Private rs As ADODB.Recordset
Private rowcnt, id, i As Integer
Private strQry As String

Private Sub cmbMode_Click()

On Error Resume Next

40
If txtSearch.Text = "" Or txtSearch.Text = "Nume" Or txtSearch.Text = "Data
nastere" Or txtSearch.Text = "Tel Mobil" Or txtSearch.Text = "Prenume" Then
txtSearch.Text = cmbMode.Text

End If

txtSearch.Text = ""

End Sub

Private Sub cmdAdd_Click()

On Error Resume Next

frmNew.id = 0
frmNew.cmdDel.Enabled = False

frmNew.Show 1
End Sub

Private Sub cmdCancel_Click()

On Error Resume Next

End
End Sub

Private Sub cmdDelete_Click()


Dim iMsg As Integer

On Error Resume Next

If id <> "" Then


iMsg = MsgBox("Sterge aceasta inregistrare " &
GRDApp.TextMatrix(GRDApp.RowSel, 0), vbYesNo, "Sterge inregistrarea")
If iMsg = 7 Then
Exit Sub
Else
conn.Execute ("delete * from AddressBook where ID = " & id)
cmdFind_Click
End If

41
End If
End Sub

Private Sub cmdEdit_Click()

On Error Resume Next

If id <= 0 Then
MsgBox "Te rog selecteaza o inregistrare ", vbCritical
GRDApp.SetFocus
Exit Sub
End If
frmNew.id = id
frmNew.Show 1
End Sub

Private Sub cmdFind_Click()

makeGrid (cmbMode.Text)
If GRDApp.TextMatrix(1, 0) = "" Then
MsgBox "Nu am gasit ce cautati ", vbCritical, "Agenda"
End If
End Sub

Private Sub Command1_Click()

On Error Resume Next

If optAll.Value Then
strQry = "select * from AddressBook order by Nme"
If rs.State = 1 Then
rs.Close
End If
rs.Open strQry, conn, adOpenKeyset, adLockOptimistic
End If
If optAdrOnly.Value Then
With rptAddressList
Set .DataSource = rs
.DataMember = rs.DataMember
DoEvents
If optPreview Then

42
.Show

End If
End With
End If
If optBoth.Value Then
With rptAllDetList
Set .DataSource = rs
.DataMember = rs.DataMember
DoEvents
If optPreview Then
.Show

End If
End With

End If
If optTelOnly.Value Then
With rptTellList
Set .DataSource = rs
.DataMember = rs.DataMember
DoEvents
If optPreview Then
.Show

End If
End With

End If

Frame1.Enabled = True
Frame2.Enabled = True
GRDApp.Enabled = True
End Sub

Private Sub Command2_Click()

On Error Resume Next

Frame1.Enabled = True
Frame2.Enabled = True
GRDApp.Enabled = True

End Sub

43
Private Sub Form_Activate()

On Error Resume Next

id = 0
makeGrid ("Afiseaza tot")
cmdFind_Click
End Sub

Private Sub Form_Load()

On Error Resume Next

Set rs = New ADODB.Recordset


'Move (frmMDI.Frame2.Left + frmMDI.Frame2.Width + 500), 0
cmbMode.AddItem ("Nume")
cmbMode.AddItem ("Prenume")
cmbMode.AddItem ("Tel Mobil")
cmbMode.AddItem ("Data nastere")
cmbMode.AddItem ("Afiseaza tot")
cmbMode.Text = "Afiseaza tot"
GRDApp.Cols = 5
GRDApp.ColWidth(0) = 3000
GRDApp.ColWidth(1) = 3500
GRDApp.ColWidth(2) = 1400
GRDApp.ColWidth(3) = 3000
gridHeader

cmdFind_Click
End Sub
Private Sub makeGrid(qryField As String)

On Error Resume Next

If rs.State = 1 Then
rs.Close
End If
Select Case qryField
Case "Afiseaza tot":

44
strQry = "SELECT * FROM AddressBook ORDER BY Nme"
Case "Nume":
strQry = "SELECT * FROM AddressBook WHERE Nme LIKE '%" &
Trim(txtSearch.Text) & "%' ORDER BY Nme"
Case "Prenume":
strQry = "SELECT * FROM AddressBook WHERE hno LIKE '%" &
Trim(txtSearch.Text) & "%' ORDER BY Nme"
Case "Data nastere":
strQry = "SELECT * FROM AddressBook WHERE town LIKE '%" &
Trim(txtSearch.Text) & "%' ORDER BY Nme"
Case "Tel Mobil":
strQry = "SELECT * FROM AddressBook WHERE mobile LIKE '%" &
Trim(txtSearch.Text) & "%' ORDER BY Nme"
End Select

rs.Open strQry, conn, adOpenKeyset, adLockReadOnly


If rs.RecordCount < 1 Then
GRDApp.Clear
GRDApp.Rows = 2
gridHeader
Else
rs.MoveFirst
GRDApp.Rows = rs.RecordCount + 1
rowcnt = 1
For i = 1 To rs.RecordCount
GRDApp.Row = rowcnt
GRDApp.Col = 0
GRDApp.RowHeight(rowcnt) = 350
GRDApp.Text = "" & rs.Fields("Title") & " " & rs.Fields("Nme")
GRDApp.Col = 1
GRDApp.Text = "" & rs.Fields("Town") & ", " & rs.Fields("City")
GRDApp.Col = 2
GRDApp.Text = "" & rs.Fields("PostCode")
GRDApp.Col = 3
GRDApp.Text = "" & rs.Fields("Home") & ", " & rs.Fields("Mobile")

GRDApp.Col = 4
GRDApp.Text = "" & rs.Fields("ID")
rs.MoveNext
rowcnt = rowcnt + 1
Next i
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)

45
On Error Resume Next
If rs.State = 1 Then
rs.Close
End If
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub

Private Sub GRDApp_Click()

On Error Resume Next

id = GRDApp.TextMatrix(GRDApp.RowSel, 4)

End Sub

Private Sub GRDApp_DblClick()

On Error Resume Next

cmdEdit_Click
End Sub

Private Sub txtSearch_GotFocus()

On Error Resume Next

If txtSearch.Text = "Nume" Or txtSearch.Text = "Afiseaza tot" Or txtSearch.Text


= "Tel Mobil" Or txtSearch.Text = "Data nastere" Or txtSearch.Text = "Prenume"
Then
txtSearch.Text = ""
End If
End Sub

Private Sub gridHeader()

On Error Resume Next

GRDApp.Row = 0

46
GRDApp.Col = 0
GRDApp.CellFontBold = True
GRDApp.CellFontUnderline = True
GRDApp.CellAlignment = 4
GRDApp.Text = "Nume"
GRDApp.Col = 1
GRDApp.CellFontBold = True
GRDApp.CellFontUnderline = True
GRDApp.CellAlignment = 4
GRDApp.Text = "Date Personale"
GRDApp.Col = 2
GRDApp.CellFontBold = True
GRDApp.CellFontUnderline = True
GRDApp.CellAlignment = 4
GRDApp.Text = "Cod Postal"
GRDApp.Col = 3
GRDApp.CellFontBold = True
GRDApp.CellFontUnderline = True
GRDApp.CellAlignment = 4
GRDApp.Text = "Telefon"
GRDApp.Col = 4
GRDApp.CellFontBold = True
GRDApp.CellFontUnderline = True
GRDApp.CellAlignment = 5
GRDApp.Text = "ID"
End Sub
Private Sub txtSearch_KeyPress(KeyAscii As Integer)

On Error Resume Next

If KeyAscii = 13 Then
cmdFind_Click
End If
End Sub

Form2:
Public id As Long
Dim rs As New ADODB.Recordset

Private Sub cmdDel_Click()

On Error Resume Next

If rs.RecordCount > 0 Then

47
rs.Delete
rs.Update
End If
Unload Me
End Sub

Private Sub Command1_Click()

Unload Me
End Sub

Private Sub Command2_Click()

On Error Resume Next

If Trim(txtName.Text) = "" Then


MsgBox "Te rog introdu numele", vbCritical
txtName.SetFocus
Exit Sub
End If

If rs.RecordCount > 0 Then


fillTable
Else
rs.AddNew
fillTable
End If
Unload Me
End Sub

Private Sub Command3_Click()

On Error Resume Next

Frame3.Enabled = True
Frame2.Enabled = True

End Sub

Private Sub Command4_Click()

On Error Resume Next

48
If optAdrOnly.Value Then
With rptAddressList
Set .DataSource = rs
.DataMember = rs.DataMember
DoEvents
If optPreview Then
.Show 1

End If
End With
End If
If optBoth.Value Then
With rptAllDetList
Set .DataSource = rs
.DataMember = rs.DataMember
DoEvents

End With

End If
If optTelOnly.Value Then
With rptTellList
Set .DataSource = rs
.DataMember = rs.DataMember
DoEvents
If optPreview Then
.Show 1

End If
End With
End If
Frame3.Enabled = True
Frame2.Enabled = True

End Sub

Private Sub Command5_Click()

On Error Resume Next

Frame3.Enabled = False
Frame2.Enabled = False

49
End Sub

Private Sub Command6_Click()

On Error Resume Next

Frame3.Enabled = True
Frame2.Enabled = True

End Sub

Private Sub Command7_Click()

Dim phNo As String


If optHome Then
If Not IsNumeric(Trim(txtHome.Text)) Then
MsgBox "Numar de telefon incorect"
Command6_Click
txtHome.SetFocus
Exit Sub
Else
phNo = txtHome.Text
End If
End If
If optMobile Then
If Not IsNumeric(Trim(txtMob.Text)) Then
MsgBox "Numar de telefon incorect"
Command6_Click
txtMob.SetFocus
Exit Sub
Else
phNo = txtMob.Text
End If
End If

If optWork Then
If Not IsNumeric(Trim(txtWork.Text)) Then
MsgBox "Numar de telefon incorect"
Command6_Click
txtWork.SetFocus
Exit Sub
Else
phNo = txtWork.Text
End If

50
End If

End Sub

Private Sub Form_Activate()

On Error Resume Next

If rs.State = 1 Then
rs.Close
End If
rs.Open "select * from AddressBook where ID = " & id, conn, adOpenKeyset,
adLockOptimistic
If rs.RecordCount > 0 Then
fillData
End If
End Sub

Private Sub fillData()

On Error Resume Next

cmbTitle.Text = "" & rs("Title")


cmbGroup.Text = "" & rs("Group")
txtName.Text = "" & rs("Nme")
txtCity.Text = "" & rs("City")
txtCountry.Text = "" & rs("Country")
txtEmail.Text = "" & rs("Email")
txtHno.Text = "" & rs("Hno")
txtHome.Text = "" & rs("Home")
txtMob.Text = "" & rs("Mobile")
txtNotes.Text = "" & rs("Notes")
txtOther.Text = "" & rs("Other")
txtPost.Text = "" & rs("PostCode")
txtStreet.Text = "" & rs("Street")
txtTown.Text = "" & rs("Town")
txtWork.Text = "" & rs("Work")
End Sub
Private Sub fillTable()

On Error Resume Next

51
rs("Title") = "" & UCase(cmbTitle.Text)
rs("Group") = "" & UCase(cmbGroup.Text)
rs("Nme") = "" & UCase(txtName.Text)
rs("City") = "" & UCase(txtCity.Text)
rs("Country") = "" & UCase(txtCountry.Text)
rs("Email") = "" & txtEmail.Text
rs("Hno") = "" & txtHno.Text
rs("Home") = "" & txtHome.Text
rs("Mobile") = "" & txtMob.Text
rs("Notes") = "" & txtNotes.Text
rs("Other") = "" & txtOther.Text
rs("PostCode") = "" & UCase(txtPost.Text)
rs("Street") = "" & UCase(txtStreet.Text)
rs("Town") = "" & UCase(txtTown.Text)
rs("Work") = "" & txtWork.Text
rs.Update
End Sub

Private Sub Form_Load()

On Error Resume Next

cmbTitle.Text = "Dl."
cmbGroup.Text = "Prieteni"
End Sub

Private Sub Form_Unload(Cancel As Integer)

On Error Resume Next

rs.Close
Set rs = Nothing

End Sub

Private Sub txtCity_KeyPress(KeyAscii As Integer)

On Error Resume Next

If KeyAscii = 13 Then
txtPost.SetFocus
End If

52
End Sub

Private Sub txtCountry_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
cmbGroup.SetFocus
End If
End Sub

Private Sub txtEmail_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtNotes.SetFocus
End If
End Sub

Private Sub txtHno_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtStreet.SetFocus
End If
End Sub

Private Sub txtHome_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtMob.SetFocus

End If
End Sub

Private Sub txtMob_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtWork.SetFocus
End If
End Sub

Private Sub txtName_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtHno.SetFocus
End If
End Sub

53
Private Sub txtOther_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtEmail.SetFocus
End If
End Sub

Private Sub txtPost_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtCountry.SetFocus
End If
End Sub

Private Sub txtStreet_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtTown.SetFocus
End If
End Sub

Private Sub txtTown_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtCity.SetFocus
End If
End Sub

Private Sub txtWork_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtOther.SetFocus
End If
End Sub

54
4. Calculator (problema 2 pagina 242)

Dim a As String
Dim b As Double
Dim c As Double
Dim Remind As Double

Private Sub Command1_Click()


a = "+"
b = Val(Text1.Text)
Text1.Text = ""
Text1.SetFocus
End Sub

Private Sub Command10_Click()


If Text1.Text = "" Then
Text1.Text = "1"
Else
Text1.Text = Text1.Text + Right("1", Len(Text1.Text))
End If
End Sub

Private Sub Command11_Click()


If Text1.Text = "" Then
Text1.Text = "7"

55
Else
Text1.Text = Text1.Text + Right("7", Len(Text1.Text))
End If
End Sub

Private Sub Command12_Click()


If Text1.Text = "" Then
Text1.Text = "4"
Else
Text1.Text = Text1.Text + Right("4", Len(Text1.Text))
End If
End Sub

Private Sub Command13_Click()


If Text1.Text = "" Then
Text1.Text = "0"
Else
Text1.Text = Text1.Text + Right("0", Len(Text1.Text))
End If
End Sub

Private Sub Command14_Click()


a = "*"
b = Val(Text1.Text)
Text1.Text = ""
Text1.SetFocus
End Sub

Private Sub Command15_Click()


a = "/"
b = Val(Text1.Text)
Text1.Text = ""
Text1.SetFocus
End Sub

Private Sub Command16_Click()


End
End Sub

Private Sub Command17_Click()


Text1.Text = ""
a = ""
b=0
c=0
Text1.SetFocus
End Sub

56
Private Sub Command18_Click()
Text1.Text = -Val(Text1.Text)
End Sub

Private Sub Command19_Click()


If Text1.Text = "" Then
Text1.Text = "0."
Else
Text1.Text = Text1.Text + Right(".", Len(Text1.Text))
End If
End Sub

Private Sub Command2_Click()


If Val(Text1.Text) = 0 Then
c=0
End If
c = Val(Text1.Text)
If a = "+" Then
Text1.Text = b + c
ElseIf a = "-" Then
Text1.Text = b - c
ElseIf a = "*" Then
Text1.Text = b * c
ElseIf a = "/" Then
Text1.Text = b / c
End If
End Sub

Private Sub Command20_Click()


Remind = Text1.Text
a = "+"
Text2.Text = "M"
End Sub

Private Sub Command21_Click()


Remind = Text1.Text
a = "-"
Text2.Text = "M"
End Sub

Private Sub Command22_Click()


Text1.Text = Remind
End Sub

Private Sub Command23_Click()

57
Remind = "0"
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Command3_Click()


a = "-"
b = Val(Text1.Text)
Text1.Text = ""
Text1.SetFocus
End Sub

Private Sub Command4_Click()


If Text1.Text = "" Then
Text1.Text = "3"
Else
Text1.Text = Text1.Text + Right("3", Len(Text1.Text))
End If
End Sub

Private Sub Command5_Click()


If Text1.Text = "" Then
Text1.Text = "9"
Else
Text1.Text = Text1.Text + Right("9", Len(Text1.Text))
End If
End Sub

Private Sub Command6_Click()


If Text1.Text = "" Then
Text1.Text = "6"
Else
Text1.Text = Text1.Text + Right("6", Len(Text1.Text))
End If
End Sub

Private Sub Command7_Click()


If Text1.Text = "" Then
Text1.Text = "2"
Else
Text1.Text = Text1.Text + Right("2", Len(Text1.Text))
End If
End Sub

Private Sub Command8_Click()


If Text1.Text = "" Then

58
Text1.Text = "8"
Else
Text1.Text = Text1.Text + Right("8", Len(Text1.Text))
End If
End Sub

Private Sub Command9_Click()


If Text1.Text = "" Then
Text1.Text = "5"
Else
Text1.Text = Text1.Text + Right("5", Len(Text1.Text))
End If
End Sub

Private Sub Form_Activate()


Text1.SetFocus
End Sub

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)


Select Case KeyCode
Case vbKeyAdd
KeyCode = 0
Command1_Click
Case vbKeySubtract
KeyCode = 0
Command3_Click
Case vbKeyDivide
KeyCode = 0
Command15_Click
Case vbKeyMultiply
KeyCode = 0
Command14_Click
Case vbKeyReturn
KeyCode = 0
Command2_Click
End Select
End Sub

59
5. Complex magazine (problema 12 pagina 244)

Dim a(1 To 100, 1 To 100), s1(1 To 100), s2(1 To 100), min, max, med As
Double
Dim m, n, i, j As Integer
Private Sub Command1_Click()
Text1.Text = ""
m = InputBox("Numarul de magazine = ")
n = InputBox("Numarul de luni = ")
For i = 1 To m
Text1.Text = Text1.Text + "Magazin " + Str(i) + " valoare vanzari: "
For j = 1 To n
a(i, j) = InputBox(" Vanzari magazin " & i & " pt luna " & j & " = ")
Text1.Text = Text1.Text + Str(a(i, j)) + " "
Next j
Text1.Text = Text1.Text & vbCrLf
Next i
Text1.Text = Text1.Text & vbCrLf

End Sub

Private Sub Command2_Click()


For i = 1 To m
s1(i) = 0

60
For j = 1 To n
s1(i) = s1(i) + a(i, j)
Next j
Text1.Text = Text1.Text + "Volumul vanzarilor pentru magazinul " + Str(i) + "
este " + Str(s1(i))
Text1.Text = Text1.Text & vbCrLf
Next i
Text1.Text = Text1.Text & vbCrLf
End Sub

Private Sub Command3_Click()


For j = 1 To n
s2(j) = 0
For i = 1 To m
s2(j) = s2(j) + a(i, j)
Next i
Text1.Text = Text1.Text + "Volumul vanzarilor pentru luna " + Str(j) + " este "
+ Str(s2(j))
Text1.Text = Text1.Text & vbCrLf
Next j
Text1.Text = Text1.Text & vbCrLf
End Sub

Private Sub Command4_Click()


max = a(1, 1)
For i = 1 To m
For j = 1 To n
If max < a(i, j) Then
max = a(i, j)
End If
Next j
Next i
Text1.Text = Text1.Text + "Valoarea vanzarii maxime este = " + Str(max)
Text1.Text = Text1.Text & vbCrLf
Text1.Text = Text1.Text & vbCrLf

End Sub

Private Sub Command5_Click()


min = a(1, 1)
For i = 1 To m
For j = 1 To n
If min > a(i, j) Then
min = a(i, j)
End If
Next j

61
Next i
Text1.Text = Text1.Text + "Valoarea vanzarii minime este = " + Str(min)
Text1.Text = Text1.Text & vbCrLf
Text1.Text = Text1.Text & vbCrLf
End Sub

Private Sub Command6_Click()


For i = 1 To m

Text1.Text = Text1.Text + "Valoarea vanzarii medii pentru magazinul " + Str(i)


+ " este " + Str(s1(i) / n)
Text1.Text = Text1.Text & vbCrLf
Next i
Text1.Text = Text1.Text & vbCrLf
End Sub

Private Sub Command7_Click()


For j = 1 To n
Text1.Text = Text1.Text + "Valoarea vanzarii medii a magazinelor in luna " +
Str(j) + " este " + Str(s2(j) / m)
Text1.Text = Text1.Text & vbCrLf
Next j
Text1.Text = Text1.Text & vbCrLf
End Sub

Private Sub Command8_Click()


med = 0
For i = 1 To m
med = med + s1(i)
Next i
Text1.Text = Text1.Text + "Valaloarea vanzarii medii complexului este " +
Str(med / (n * m))
Text1.Text = Text1.Text & vbCrLf
Text1.Text = Text1.Text & vbCrLf
End Sub

Private Sub Command9_Click()


End
End Sub

62
6. Interclasare a 2 vectori (problema 8 pagina 244)

Dim x(1 To 100) As Integer


Dim y(1 To 100) As Integer
Dim z(1 To 200) As Integer
Dim m, n, i, j, k, p As Integer

Private Sub cit1()


Text1.Text = "Elementele vectorului X : "
m = InputBox("Introduceti numarul de elemente ale primului vector ")
For i = 1 To m
x(i) = InputBox(" Introduceti X ( " & i & " ) = ")
Text1.Text = Text1.Text + Str(x(i)) + " "
Next i
End Sub

Private Sub cit2()


Text2.Text = "Elementele vectorului Y : "
n = InputBox("Introduceti numarul de elemente ale celui de-al doilea vector ")
For i = 1 To n
y(i) = InputBox(" Introduceti Y ( " & i & " ) = ")
Text2.Text = Text2.Text + Str(y(i)) + " "
Next i
End Sub

Private Sub afis()


i=1
j=1
k=1

Do
If x(i) < y(j) Then
z(k) = x(i)
i=i+1

63
Else
z(k) = y(j)
j=j+1
End If
k=k+1
Loop While (Int(i) <= Int(m)) And (Int(j) <= Int(n))

If Int(i) < Int(m) Then


Do
z(k) = x(i)
i=i+1
k=k+1
Loop While (Int(i) <= Int(m))
Else
If Int(j) < Int(n) Then
Do
z(k) = y(j)
j=j+1
k=k+1
Loop While (Int(j) <= Int(n))
End If
End If
p = Int(n) + Int(m)

Text3.Text = "Interclasarea lui X cu Y este: "

For k = 1 To p
Text3.Text = Text3.Text + Str(z(k)) + " "
Next k

End Sub

Private Sub Command1_Click()


Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
cit1
cit2
afis
End Sub

Private Sub Command5_Click()


End
End Sub

64
7. Magazia de produse hardware ( problema 5 pagina 243)

Private Inregistrare() As New Inregistrare

Private Sub Command1_Click()


End
End Sub

Private Sub Form_Load()

ReDim Inregistrare(0)

End Sub

Public Function constructor(id As Integer, nr As String, detalii_produs As String, _


raionul As String, raft As String, pret As Integer)

Inregistrare(id).nr = nr

65
Inregistrare(id).detalii_produs = detalii_produs
Inregistrare(id).raionul = raionul
Inregistrare(id).raft = raft
Inregistrare(id).pret = pret

End Function

Private Sub deleteObj_Click()


Dim i As Long
Dim j As Long
Dim k As Long
Dim nr As String

j = UBound(Inregistrare)
nr = nameInput.Text

Do
If nr = Inregistrare(i).nr Then Exit Do
If i < j Then
i=i+1
Else
MsgBox "Nu gasesc produsul", vbOKOnly, "Nu se poate sterge produsul"
Exit Sub
End If
Loop

Set Inregistrare(i) = Nothing

Dim tmp() As Object


ReDim tmp(UBound(Inregistrare))

For j = 0 To i - 1
Set tmp(k) = Inregistrare(j)
k=k+1
Next

For j = i + 1 To UBound(Inregistrare)
Set tmp(k) = Inregistrare(j)
k=k+1
Next

If UBound(Inregistrare) <> 0 Then ReDim Inregistrare(UBound(Inregistrare) - 1)

For i = 0 To UBound(Inregistrare)
Set Inregistrare(i) = tmp(i)
Next

66
Call showEntries

End Sub

Private Sub createObj_Click()

Dim nr As String
Dim pret As Integer
Dim detalii_produs As String
Dim raionul As String
Dim raft As String

nr = Trim(nameInput.Text)
pret = val(ageInput.Text)
detalii_produs = Trim(addressInput.Text)
raionul = Trim(countryInput.Text)
raft = Trim(stateInput.Text)

If nr = vbNullString Then
MsgBox "Campul Cod produs este gol", vbOKOnly, "Toate campurile trebuie sa
contina date"
Exit Sub
ElseIf Str(pret) = 0 Then
MsgBox "Campul Pret este gol", vbOKOnly, "Toate campurile trebuie sa contina
date"
Exit Sub
ElseIf detalii_produs = vbNullString Then
MsgBox "Campul Detalii produs este gol", vbOKOnly, "Toate campurile trebuie
sa contina date"
Exit Sub
ElseIf raionul = vbNullString Then
MsgBox "Campul Raion este gol", vbOKOnly, "Toate campurile trebuie sa
contina date"
Exit Sub
ElseIf raft = vbNullString Then
MsgBox "Campul Raft este gol", vbOKOnly, "Toate campurile trebuie sa contina
date"
Exit Sub

Exit Sub
End If

Dim i As Integer

For i = 0 To UBound(Inregistrare)

67
If (Inregistrare(i).nr = nr) Then
MsgBox "Produs deja inregistrat", vbOKOnly, "Nu se poate adauga"
Exit Sub
End If
Next

i = UBound(Inregistrare)
ReDim Preserve Inregistrare(i + 1)

Call constructor(i, nr, detalii_produs, raionul, raft, pret)

Call showEntries

erase_Click

End Sub

Public Function showEntries()

Dim i As Long
instances.Text = vbNullString

For i = 0 To UBound(Inregistrare)
If Not Inregistrare(i).nr = vbNullString Then
instances.Text = instances.Text & vbNewLine & "Cod produs :"&
Inregistrare(i).nr & vbNewLine
instances.Text = instances.Text & "Pret : " & Inregistrare(i).pret &
vbNewLine
instances.Text = instances.Text & "Detalii_produs : " &
Inregistrare(i).detalii_produs & vbNewLine
instances.Text = instances.Text & "Raionul : " & Inregistrare(i).raionul
& vbNewLine
instances.Text = instances.Text & "Raft : " & Inregistrare(i).raft &
vbNewLine

End If
Next

totalObj.Text = UBound(Inregistrare)
instances.Text = instances.Text & vbNewLine

End Function

Private Sub erase_Click()

nameInput.Text = vbNullString

68
ageInput.Text = vbNullString
addressInput.Text = vbNullString
countryInput.Text = vbNullString
stateInput.Text = vbNullString

End Sub

8. Minimul si maximul dintr-un vector (problema 9 pagina 244)

Dim v(1 To 100) As Long

Dim i, n, min, a, max, b As Long


Private Sub Command1_Click()
Print blank
Text1.Text = "Elemetele Vectorului sunt: "
n = InputBox("Introduceti numarul de elemente ale vectorului")
For i = 1 To n
v(i) = InputBox("Introdu v ( " & i & " ) = ")
Text1.Text = Text1.Text + Str(v(i)) + " "
Next i
afis
End Sub

Private Sub calcul()


min = v(1)
a=1
max = v(1)
b=1

69
For i = 1 To n
If min > v(i) Then
min = v(i)
a=i
End If
If max < v(i) Then
max = v(i)
b=i
End If
Next i
End Sub

Private Sub afis()


Print blank
calcul
Text2.Text = "Minimul este " + Str(min) + " la pozitia " + Str(a)
For i = 1 To n
If min = v(i) And i <> a Then
Text2.Text = Text2.Text + " si la pozitia " + Str(i)

End If
Next i

Text3.Text = "Maximul este " + Str(max) + " la pozitia " + Str(b)


For i = 1 To n
If max = v(i) And i <> b Then
Text3.Text = Text3.Text + " si la pozitia " + Str(i)

End If
Next i
End Sub

Private Sub Command4_Click() 'EXIT


End
End Sub

70
9. Sortarea unui vector prin metoda bulelor (problema 6 pagina 244)

Dim v(1 To 100) As Integer


Dim i, n, aux As Integer
Dim gasit As Boolean

Private Sub Command1_Click()


Text1.Text = "Vectorul este: "
n = InputBox("Introduceti numarul de elemente ale vectorului")
For i = 1 To n
v(i) = InputBox("Introdu v ( " & i & " ) = ")
Text1.Text = Text1.Text + Str(v(i)) + " "
Next i
sort
afis
End Sub

Private Sub sort()


Do
gasit = False
For i = 1 To n - 1
If v(i) > v(i + 1) Then
aux = v(i)
v(i) = v(i + 1)
v(i + 1) = aux
gasit = True
End If
Next i
Loop While gasit
End Sub

Private Sub afis()


Text2.Text = " Vectorul sortat este: "
For i = 1 To n
Text2.Text = Text2.Text + Str(v(i)) + " "

71
Next i
End Sub

Private Sub Command4_Click()


End
End Sub

10. Inchirieri casete video si DVD (problema 12 pagina 248)

Form1:

Dim x As Integer
Private Sub Command1_Click() 'EXIT
End
End Sub

Private Sub Command2_Click() 'Verifica


If x >= 10 Then
MsgBox "Ati introdus parola gresita de 10 ori!Toate accesele sunt blocate!",
vbCritical, Eroare
Form1.Text1.Visible = False
Form1.Command2.Visible = False
Else

72
If Form1.Text1 = "alexandra" And x < 10 Then
Form1.Hide
Form2.Show

Else
MsgBox "Parola gresita! Mai introduceti odata!", vbExclamation, "Securitate"
x=x+1
Text1.SetFocus
SendKeys "{home}+{end}"

End If
End If
If x >= 10 Then
MsgBox "Ati introdus parola gresita de 10 ori!Toate accesele sunt blocate!",
vbCritical, Eroare, "Securitate"
Form1.Text1.Visible = False
Form1.Command2.Visible = False

End If
End Sub

Private Sub Form_Load()


Form1.Text1 = Empty
AutoSize = True
Stretch = False
Form1.Picture1.Visible = True
Form1.Picture1.Picture = LoadPicture("fundal.jpg")
x=0
Text1.Text = "Introduceti parola"
SendKeys "{home}+{end}"
End Sub

Private Sub Text1_Change()


If Text1.Text = "Introduceti parola" Then
Text1.PasswordChar = ""
Else
Text1.PasswordChar = "*"
End If

End Sub

73
Form2:

Dim actor, tema, linia As String


Private Sub Combo1_Click() 'Tipuri de filme
Form2.Label2.Visible = True
Form2.List1.Visible = True

If Form2.Combo1.Text = "Actiune" Then


Form2.List1.Clear
Form2.List1.AddItem ("A fost odata in Cuba")
Form2.List1.AddItem ("Razbunarea")
Form2.List1.AddItem ("Jaful")

Form2.List1.Refresh
End If
If Form2.Combo1.Text = "Aventura" Then
Form2.List1.Clear
Form2.List1.AddItem ("Cascadorul")
Form2.List1.AddItem ("Lumea apelor")

End If
If Form2.Combo1.Text = "Comedie" Then

74
Form2.List1.Clear
Form2.List1.AddItem ("Asa vreau eu")
Form2.List1.AddItem ("O femeie drept rasplata")

End If
If Form2.Combo1.Text = "Horror" Then
Form2.List1.Clear
Form2.List1.AddItem ("Avionul Groazei")
Form2.List1.AddItem ("Sperietoarea")

End If
If Form2.Combo1.Text = "Desene Animate" Then
Form2.List1.Clear
Form2.List1.AddItem ("Alba ca zapada")
Form2.List1.AddItem ("Cartea junglei")

End If
If Form2.Combo1.Text = "Thriller" Then
Form2.List1.Clear
Form2.List1.AddItem ("Scarface")
Form2.List1.AddItem ("Asasinul")

End If
If Form2.Combo1.Text = "All" Then
Form2.List1.Clear
Form2.List1.AddItem ("A fost odata in Cuba")
Form2.List1.AddItem ("Razbunarea")
Form2.List1.AddItem ("Jaful")

Form2.List1.AddItem ("Cascadorul")
Form2.List1.AddItem ("Lumea apelor")

Form2.List1.AddItem ("Asa vreau eu")


Form2.List1.AddItem ("O femeie drept rasplata")

Form2.List1.AddItem ("Avionul Groazei")


Form2.List1.AddItem ("Sperietoarea")

Form2.List1.AddItem ("Alba ca zapada")


Form2.List1.AddItem ("Cartea junglei")

Form2.List1.AddItem ("Scarface")
Form2.List1.AddItem ("Asasinul")

End If

75
End Sub

Private Sub Despre_Click()


MsgBox "Aceasta aplicatie a fost creata de Croitoru Alexandra - Grupa 602",
vbInformation, "Despre autor"
End Sub

Private Sub Form_Load()


Form2.Label2.Visible = False
Form2.Label3.Visible = False
Form2.Label4.Visible = False
Form2.Text1.Visible = False
Form2.Text2.Visible = False
Form2.List1.Visible = False
Form2.Picture1.Visible = False
AutoSize = True
Stretch = False
Form2.Text1 = Empty
Form2.Text2 = Empty
Form2.Combo1.Text = "Alege genul"
Form2.Combo1.AddItem ("Actiune")
Form2.Combo1.AddItem ("Aventura")
Form2.Combo1.AddItem ("Comedie")
Form2.Combo1.AddItem ("Horror")
Form2.Combo1.AddItem ("Desene Animate")
Form2.Combo1.AddItem ("Thriller")
Form2.Combo1.AddItem ("All")
End Sub

Private Sub Iesire_Click()


End
End Sub

Private Sub List1_Click() 'Denumiri filme

Form2.Label3.Visible = True
Form2.Label4.Visible = True
Form2.Text1.Visible = True
Form2.Text2.Visible = True
Form2.Picture1.Visible = True

If Form2.Combo1.Text = "Actiune" Then


Select Case Form2.List1.ListIndex
Case 0

76
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\cuba.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1

Form2.Picture1.Picture = LoadPicture("data\cuba.jpg")

Case 1
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\razbunarea.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\razbunarea.jpg")
Case 2
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\jaful.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop

77
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\jaful.jpg")

End Select
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Form2.Combo1.Text = "Aventura" Then
Select Case Form2.List1.ListIndex
Case 0
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\cascadorul.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\cascadorul.jpg")
Case 1
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\lumea apelor.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\lumea apelor.jpg")

End Select
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Form2.Combo1.Text = "Comedie" Then

78
Select Case Form2.List1.ListIndex
Case 0
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\asa vreau eu.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\asa vreau eu.jpg")
Case 1
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\o femeie drept rasplata.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\o femeie drept rasplata.jpg")

End Select
End If
''''''''''''''''''''''''''''''''''''''''''''''''
If Form2.Combo1.Text = "Horror" Then
Select Case Form2.List1.ListIndex
Case 0
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\avionul groazei.txt" For Input As #1
Line Input #1, actor

79
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\avionul groazei.jpg")
Case 1
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\sperietoarea.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\sperietoarea.jpg")

End Select
End If
''''''''''''''''''''''''''''''''''''''''''''
If Form2.Combo1.Text = "Desene Animate" Then
Select Case Form2.List1.ListIndex
Case 0
' actor = ""
' linia = ""
' Form2.Text1 = Empty
' Form2.Text2 = Empty
Open "data\Alba ca zapada.txt" For Input As #1
' Line Input #1, actor
' Form2.Text2 = actor
Form2.Text2.Visible = False
Form2.Label4.Visible = False

tema = ""
Do While Not (EOF(1))
Line Input #1, linia

80
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\alba ca zapada.jpg")
Case 1
' actor = ""
' linia = ""
' Form2.Text1 = Empty
' Form2.Text2 = Empty
Open "data\cartea junglei.txt" For Input As #1
' Line Input #1, actor
' Form2.Text2 = actor
Form2.Text2.Visible = False
Form2.Label4.Visible = False
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\cartea junglei.jpg")

End Select
End If
'''''''''''''''''''''''''''''''''''''
If Form2.Combo1.Text = "Thriller" Then
Select Case Form2.List1.ListIndex
Case 0
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\scarface.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\scarface.jpg")
Case 1

81
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\asasinul.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\asasinul.jpg")

End Select
End If
'''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''
If Form2.Combo1.Text = "All" Then
Select Case Form2.List1.ListIndex
Case 0
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\cuba.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1

Form2.Picture1.Picture = LoadPicture("data\cuba.jpg")

Case 1
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\razbunarea.txt" For Input As #1

82
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\razbunarea.jpg")
Case 2
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\jaful.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\jaful.jpg")

Case 3
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\cascadorul.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\cascadorul.jpg")
Case 4
actor = ""
linia = ""

83
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\lumea apelor.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\lumea apelor.jpg")

Case 5
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\asa vreau eu.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\asa vreau eu.jpg")
Case 6
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\o femeie drept rasplata.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\o femeie drept rasplata.jpg")

84
Case 7
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\avionul groazei.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\avionul groazei.jpg")
Case 8
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\sperietoarea.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\sperietoarea.jpg")

Case 9
' actor = ""
' linia = ""
' Form2.Text1 = Empty
' Form2.Text2 = Empty
Open "data\Alba ca zapada.txt" For Input As #1
' Line Input #1, actor
' Form2.Text2 = actor
Form2.Text2.Visible = False
Form2.Label4.Visible = False

85
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\alba ca zapada.jpg")
Case 10
' actor = ""
' linia = ""
' Form2.Text1 = Empty
' Form2.Text2 = Empty
Open "data\cartea junglei.txt" For Input As #1
' Line Input #1, actor
' Form2.Text2 = actor
Form2.Text2.Visible = False
Form2.Label4.Visible = False
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\cartea junglei.jpg")
Case 11
actor = ""
linia = ""
Form2.Text1 = Empty
Form2.Text2 = Empty
Open "data\scarface.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\scarface.jpg")
Case 12
actor = ""
linia = ""
Form2.Text1 = Empty

86
Form2.Text2 = Empty
Open "data\asasinul.txt" For Input As #1
Line Input #1, actor
Form2.Text2 = actor
tema = ""
Do While Not (EOF(1))
Line Input #1, linia
tema = tema + linia
Loop
Form2.Text1 = tema
Close #1
Form2.Picture1.Picture = LoadPicture("data\asasinul.jpg")

End Select
End If

End Sub

87

You might also like