Professional Documents
Culture Documents
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.
27
If Len(Text1) <> 0 Then
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
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
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
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
Form1.Hide
35
Form2.Show
Form2.Command1 = True
End Sub
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
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
37
If Val(Form1.Text2.Text) > 40 Then
coef_varsta = -0.5
End If
End If
End If
rata_lunara = (Form1.Text4.Text) / 12
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
End Sub
End Sub
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
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
frmNew.id = 0
frmNew.cmdDel.Enabled = False
frmNew.Show 1
End Sub
End
End Sub
41
End If
End Sub
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
makeGrid (cmbMode.Text)
If GRDApp.TextMatrix(1, 0) = "" Then
MsgBox "Nu am gasit ce cautati ", vbCritical, "Agenda"
End If
End Sub
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
Frame1.Enabled = True
Frame2.Enabled = True
GRDApp.Enabled = True
End Sub
43
Private Sub Form_Activate()
id = 0
makeGrid ("Afiseaza tot")
cmdFind_Click
End Sub
cmdFind_Click
End Sub
Private Sub makeGrid(qryField As String)
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
GRDApp.Col = 4
GRDApp.Text = "" & rs.Fields("ID")
rs.MoveNext
rowcnt = rowcnt + 1
Next i
End If
End Sub
45
On Error Resume Next
If rs.State = 1 Then
rs.Close
End If
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub
id = GRDApp.TextMatrix(GRDApp.RowSel, 4)
End Sub
cmdEdit_Click
End Sub
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)
If KeyAscii = 13 Then
cmdFind_Click
End If
End Sub
Form2:
Public id As Long
Dim rs As New ADODB.Recordset
47
rs.Delete
rs.Update
End If
Unload Me
End Sub
Unload Me
End Sub
Frame3.Enabled = True
Frame2.Enabled = True
End Sub
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
Frame3.Enabled = False
Frame2.Enabled = False
49
End Sub
Frame3.Enabled = True
Frame2.Enabled = True
End Sub
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
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
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
cmbTitle.Text = "Dl."
cmbGroup.Text = "Prieteni"
End Sub
rs.Close
Set rs = Nothing
End Sub
If KeyAscii = 13 Then
txtPost.SetFocus
End If
52
End Sub
End If
End Sub
53
Private Sub txtOther_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtEmail.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
55
Else
Text1.Text = Text1.Text + Right("7", Len(Text1.Text))
End If
End Sub
56
Private Sub Command18_Click()
Text1.Text = -Val(Text1.Text)
End Sub
57
Remind = "0"
Text1.Text = ""
Text2.Text = ""
End Sub
58
Text1.Text = "8"
Else
Text1.Text = Text1.Text + Right("8", Len(Text1.Text))
End If
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
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
End Sub
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
62
6. Interclasare a 2 vectori (problema 8 pagina 244)
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))
For k = 1 To p
Text3.Text = Text3.Text + Str(z(k)) + " "
Next k
End Sub
64
7. Magazia de produse hardware ( problema 5 pagina 243)
ReDim Inregistrare(0)
End Sub
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
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
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
For i = 0 To UBound(Inregistrare)
Set Inregistrare(i) = tmp(i)
Next
66
Call showEntries
End Sub
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 showEntries
erase_Click
End Sub
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
nameInput.Text = vbNullString
68
ageInput.Text = vbNullString
addressInput.Text = vbNullString
countryInput.Text = vbNullString
stateInput.Text = vbNullString
End Sub
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
End If
Next i
End If
Next i
End Sub
70
9. Sortarea unui vector prin metoda bulelor (problema 6 pagina 244)
71
Next i
End Sub
Form1:
Dim x As Integer
Private Sub Command1_Click() 'EXIT
End
End Sub
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
End Sub
73
Form2:
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 ("Scarface")
Form2.List1.AddItem ("Asasinul")
End If
75
End Sub
Form2.Label3.Visible = True
Form2.Label4.Visible = True
Form2.Text1.Visible = True
Form2.Text2.Visible = True
Form2.Picture1.Visible = True
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