Primer 3- Upotreba petlji i upravljačkih struktura:

Prethodna strana


Izgled forme za primer3:

Primer 3.- .EXE verzija


Option Explicit

 

Private Sub cmdPromena_Click()

Dim ctl As Control

For Each ctl In Me

    If TypeOf ctl Is TextBox Then

        If ctl.BackColor = vbRed Then

            ctl.BackColor = vbBlue

            ctl.ForeColor = vbWhite

        Else

            ctl.BackColor = vbRed

            ctl.ForeColor = vbBlack

        End If

    End If

Next ctl

End Sub

 

Private Sub cmdProveri_Click()

Dim Indikator As Boolean

Indikator = False

If txtPolje1.Text = "" Then

    Indikator = True

Else

    If txtPolje2 = "" Then

        Indikator = True

    Else

        If txtPolje3 = "" Then Indikator = True

    End If

End If

If Indikator = True Then

    MsgBox "NISU UNETI PODACI U SVA POLJA!!!"

Else

    MsgBox "PODACI SU UNETI U SVA POLJA"

End If

End Sub

 

Private Sub cmdNadovezi_Click()

Dim ctl As Control

Dim Pom As String

Dim i As Integer

Pom = txtPolje1.Text & txtPolje2.Text & txtPolje3.Text

Do While i < 3

        For Each ctl In Me

            If TypeOf ctl Is TextBox Then

                ctl.Text = ctl.Text & Str$(i)

            End If

        Next ctl

    i = i + 1

Loop

End Sub

 

Private Sub cmdSpajanje_Click()

Dim ctl As Control

Dim Pom As String

Pom = txtPolje1.Text & txtPolje2.Text & txtPolje3.Text

Select Case Pom

    Case ""

        lblRezultat.Visible = False

        For Each ctl In Me

            If TypeOf ctl Is Line Then

                ctl.Visible = False

            End If

        Next ctl

        MsgBox "SVA POLJA SU PRAZNA!!!"

    Case Else

        lblRezultat.Caption = Pom

        lblRezultat.Visible = True

        For Each ctl In Me

        If TypeOf ctl Is Line Then

            ctl.Visible = True

        End If

        Next ctl

 

End Select

End Sub


Prethodna strana