Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
listbox1,add(str)
next
end
public sub button2_click()
listbox2.clear
dim str as string
dim i,j as string
for i=1 to counterRow
str=” “
for j= 1 to counterCol
matrix2[i,j]= matrix[j,i]
str=str & space$(3) & matrix2[i,j]
next
listbox2.add(str)
next
end
public sub button3_click()
listbox3.clear
dim str as string
dim i,j,k as integer
for i= 1 to counterRow
str=” “
for j= 1 to counterRow
resultmatrix[i,j] = 0
for k= 1 to counterCol
resultmatrix[i,j]= resultmatrix[i,j]+matrix2[k,j]*matrix[i,k]
next
next
next
for i= 1 to counterRow
str=” “
for j=1 to counterCol
str= str & space$(3) & resultmatrix[i,j]
next
listbox3.add(str)
next
end
public sub button4_click()
Fmain.close
End
5. Swapping
Code:
Public sub swap1(x as integer, y as integer)
Dim s as integer
S= x
X= y
Y=s
Textbox1.text =x
Textbox2.text=y
End
Public sub button1_click()
Dim x1,y1 as integer
X1= val(textbox1.text)
Y1= val(textbox2.text)
Swap(x1,y1)
End
6. Write a program in gambas 2 to habe user i/p textbox as integer 1 to 10 to specify the height
and base of a right trabgle. Display the tringle in a listbox using string.
Code:
Public sub button1_click()
Dim x,s,i as integer
Dim str as string
Str=” “
X=val(textbox1.text)
If x<0 then
Message.info(“pattern not possible”)
Else
Message.info(“print the pattern”)
Listbox1.clear
For i=1 to x step1
Str=str &’#’
Listbox1.add(str)
Next
End if
End
7. Have the user i/p a positive number via i/p box. Use a validation loop to prompt for i/p until
valid. Display message indication when valid input is received.
Code:
Public sub button1_click()
Dim s as a string
Dim n as a integer
While true
S= inputbox(“enter a positive number”)
N=s
If n>0 then
Message.info(“valid input”)
Break
Else
Message.info(“invalid input”)
Continue
End if
Wend
End
9. Shopping cort
Code: