Properties:
Coding:
Dim arr(), pos() As Variant
Dim size As Integer
Private Sub cmddisplay_Click()
size = Val(txtsize.Text)
ReDim arr(size)
ReDim pos(size)
List1.Visible = True
Dim i As Integer: i = 0
For i = 1 To size Step 1
arr(i) = InputBox("Enter array element : ")
List1.AddItem arr(i)
Next i
cmdfrequency.Visible = True
cmddisplay.Enabled = False
End Sub
Private Sub cmdend_Click()
Unload Me
End Sub
Private Sub cmdfrequency_Click()
Dim freq As Integer
For i = 1 To size
ele = arr(i)
freq = 0
k=0
For j = 1 To size
If ele = arr(j) Then
If i > j Then
Exit For
End If
freq = freq + 1
k=k+1
pos(k) = j
End If
Next j
If k > 0 Then
Print "The frequency of " & ele & " is " & freq
Print "Element " & ele & " is found at position "
For z = 1 To k
Print pos(z) & " "
Next
End If
Next i
End Sub
OUTPUT:
1. What is the role of Dim statement?
Ans.: It is used to declare variables.
2. What is the purpose of variant?
Ans: It is generic datatype. It can hold all datatype values.
3. What is the use inputbox?
Ans: It is used to accept the value from user.
4. What is the use of print statement?
Ans: It is used to display text or value on form.
5. What is use of visible property?
Ans: It hide/ unhides control by setting its value to false/true.
6. What is the use of enabled property?
Ans: It makes control active / inactive by setting its value to true/false.
7. What is an array?
Ans: An array is a collection of elements having same name and different index no.
(subscript) of similar datatype.
8. What is a dynamic array?
Ans: It is an array of elements in which size of array is not specified at the time of
declaration but can be specified during run time.
9. What is a the use of Redim statement?
Ans: It is used to specify or modify the size of an array during run time.