Professional Documents
Culture Documents
Text box
ﻣﺮﺑﻊ ﻧﺺ
Layout window
Design time-
)(design time ﻋﻨﺪ اﻟﺘﻐﻴﺮ ﻳﻜﻮن ﻓﻲ ﻧﺎﻓﺬة اﻟﺨﺼﺎﺋﺺ
)(Run time ﻳﻜﻮن اﻟﺘﻐﻴﺮ ﻓﻲ وﻗﺖ اﻟﺘﻨﻔﻴﺬ
اﻹﺟﺮاء أﻟﺤﺪﺛﻲ)(Eevent procedure
-اﺳﻄﺮ اﻟﺸﻔﺮة ﻳﺘﻢ ﺗﻨﻔﻴﺬهﺎ ﻋﻨﺪﻣﺎ ﻳﻌﺎﻟﺞ اﻟﻤﺴﺘﺨﺪم آﺎﺋﻨﺎ ﻣﺎ ﻓﻲ اﻟﺒﺮﻧﺎﻣﺞ
ﺻﻨﺪوق اﻷدوات)(tool box
)Sub (command1-clicke
{
End sub.
a) Name:
-1ﻳﺒﺪأ ﺑﺤﺮف
-2ﻗﺪ ﻳﻜﻮن اﻻﺳﻢ ﻣﺘﻜﻮن ﻣﻦ 40ﺣﺮف
-3ﻻ ﻳﺤﺘﻮي ﻋﻠﻰ اﻹﺷﺎرات اﻟﻤﻮﺟﻮدة ﻓﻲ اﻟﻜﻲ ﺑﻮرد @ $ #
-4ﻻ ﻳﺠﻮز أن ﻧﺴﻤﻲ اﻷداﺗﻴﻦ ﺑﺎﺳﻢ واﺣﺪ ﻓﻲ اﻟﺘﻄﺒﻴﻖ
left height
width
c)Font:
command1.caption="press"
command1.font bold=true
command1.font size=20
ﻋﻨﺪ اﻟﺘﻐﻴﺮ ﻓﻲ وﻗﺖ اﻟﺘﻨﻔﻴﺬ ﻳﺠﺐ آﺘﺎﺑﺔ ﺟﻤﻠﻪ ﺑﺮﻣﺠﻴﻪ
Text1.text= VB ﻗﺪ ﻳﺄﺗﻲ ﺳﺆال ﻣﺎهﻴﺔ أدوات اﻹدﺧﺎل واﻹﺧﺮاج اﻟﻤﺴﺘﺨﺪﻣﺔ ﻓﻲ
"visual basic "
Text1="program"}
Red
green
black
yellow
Text1.fore color=VB black
( ﻟﺘﻐﻴﺮ ﺟﻤﻠﻪ ﺧﺼﺎﺋﺺ ﻓﻲ ان واﺣﺪwith text ) ﺗﺴﺘﺨﺪم اﻟﻌﺒﺎرة
With text1
.Text="program"
Back color=VBwhite
2) set Focus :
Command1.setfocus
اﻻﺳﻢ اﻻﻓﺘﺮاﺿﻲ
command1,command2
private sub command1_click()
{
End sub
a)mouse event
click ﻧﻘﺮ
DB click ﻧﻘﺮ ﻣﺰدوج
mouse move ﺣﺮآﻪ اﻟﻤﺎوس
mouse down ﺣﺮآﻪ اﻟﻤﺎوس إﻟﻰ اﻷﺳﻔﻞ
mouse up ﺣﺮآﻪ اﻟﻤﺎوس إﻟﻰ اﻷﻋﻠﻰ
Button
Shift=1 (shift)
Shift=2 (cth1)
Shift=4 (Alt)
Use text box to describe the mouse events which aver
Mouse up ,mouse down ,mouse move ,on command button
Solution:
إﻧﺸﺎء اﻟﻮاﺟﻬﺔ-1
Text box
command
2) code
3) code
Private sub text _key down(key code as integer ,shift as integer)
If key code=VBkeyf1 then
Text1.="f1 is down"
End if
End sub
Private sub text1_key press(key ascii as integer)
If key ascii=82
Text="R is pressed"
End if
End sub
ﺗﻜﻤﻠﻪ اﻟﻄﺮق أﻟﻤﺸﺘﺮآﻪ:
2) Set focus ﻳﺤﺪث ﻋﻨﺪﻣﺎ ﻳﻜﻮن اﻟﻤﻄﻠﻮب ﻣﻦ اﻷداة
3) Z order
4) Refresh
ﻳﺤﺪث ﻋﻨﺪ ﺗﺸﻐﻴﻞ أداة اﻟﺘﺮآﻴﺰ 5) Got focus
Z=(x,y)^2 z=(x/y)2
)z=(x ,y,^2 z=x/y2
اﻟﻌﻮاﻣﻞ أﻟﻤﺘﻘﺪﻣﻪ اﻷﺧﺮى هﻲ :
) ﻗﺴﻤﺔ اﻟﻌﺪد اﻟﺼﺤﻴﺢ( =/
) ﺑﺎﻗﻲ اﻟﻘﺴﻤﺔ(=mod
)اﻟﻮﻳﻪ اﻟﻌﻮاﻣﻞ(
-1اﻷﻗﻮاس
-2أﻧﺸﺎء اﻟﻌﺪد واﻟﻌﺪد اﻟﺴﺎﻟﺐ
-3اﻟﻀﺮب واﻟﻘﺴﻤﺔ
-4ﻗﺴﻤﻪ اﻟﻌﺪد اﻟﺼﺤﻴﺢ
-5ﺑﺎﻗﻲ اﻟﻘﺴﻤﺔ
-6اﻟﺠﻤﻊ واﻟﻄﺮح
-7ﺗﺴﺘﺨﺪم اﻷﻗﻮاس ﻟﻠﺘﺤﻜﻢ ﺑﺴﻴﺮ اﻟﻌﻤﻠﻴﺎت
اﻟﺪوال اﻟﻤﻜﺘﺒﻴﺔ )(Library function
رﻳﺎﺿﻴﺎ ﺑﺮﻣﺠﻴﺎ
sinx )sin(x
cos x )cos(x
tan x )tan(x
log(x)+((x+2*7)/3)^1/2
Ex:-
y= sqrt((2*x+3.4*log(x+1)/(2+y+3.1*x/y+2))
y= cos (x)*sin(x)/exp(x^2)+log(z)
EX :use text box to input the value angle in degrees used so 3
labels command button so that after click on it application will
writ sin , cos & tan in labels?
solution:-
option explicit
const pi as single=3.14156
private sub command1_ click()
dim x as single
x=(sng(text))
x=x*pi/180
label1.caption="sinx&sin(x)"
label2="cos&cos(x)"
label3=tan(x)
end sub
EX :use text box to input true of y also use input the value of x
in degree transform it to radian, z=3.2 use this values to obtain
the value of m in this equation:
write the value of m in label, use message box with button number
of 1 so that cancel will repeat procedure to input the value again.
solution:-
1 ok VB Ok
2 cancel VB Cancel
3 abort VB Abort
4 retry VB Retry
5 ignore VB Ignore
6 yes VB Yes
7 no No
اﻧﻮاع اﻟﺒﻴﺎﻧﺎت
اﻟﻌﻼﻣﻪ اﻟﻤﺪى اﻟﺤﺠﻢ ﻧﻮع اﻟﺒﻴﺎن
% ± 32767 2byte integer
& ±2,147, 488,643 4byte long integer
! ± 3,402823*10 4byte single
ﻗﺪ ﻳﺎﺗﻲ ﺑﺎﻟﺴﺆال ﻣﺎ ﻣﻌﻨﻰ رﻣﺰ ﻣﻦ اﻟﺮﻣﻮز اﻋﻼﻩ ﻓﻨﻜﺘﺐ وﻣﻌﻨﺎﻩ هﻜﺬا
% integer 2byte+-32767 such as
0 65535 8byte string
Variantآﻞ ﺷﺊ ﻳﺴﺘﺨﺪم 16byteآﻞ اﻧﻮاع اﻟﺒﻴﺎﻧﺎت
ﻗﺪ ﻳﺎﺗﻲ ﺑﺎﻟﺴﺆال ﻟﻤﺎذا ﺗﺤﺪد ﻧﻮع اﻟﺒﻴﺎﻧﺎت ﻓﻲ اﻟﻔﻴﺠﻮل ﺑﻴﺴﻚ ﻳﻜﻮن اﻟﺠﻮاب
اﻟﺠﻮاب هﺬا اﻟﻤﺜﺎل:
For I= 110,10000
X=x+I 2*10000=20000 byte
next 16*10000=160000 byte
A=1
B=2
C=A+B A=1
ﻟﺮﺑﻂ ﺑﻴﻦ ﺟﻤﻞ ﻋﺪﻩ وﺟﻌﻠﻬﺎ ﺗﻜﺘﺐ ﻓﻲ ﺳﻄﺮ و اﺣﺪ اﺧﺘﺼﺎرا ﻟﻠﺤﺠﻢ ﺗﺴﺘﺨﺪم : collon
A=1:B=2 :C=A+B
Option explicit
public x y ﻻﻳﺠﻮز آﺘﺎﺑﻪ
ﻳﺼﺢ آﺘﺎﺑﺘﻬﺎ داﺧﻞ وﺧﺎرج اﻻﺟﺮاءdim ﻟﻜﻦ
public x yآﻴﻒ ﺗﻌﻠﻦ ﻋﻦ ﻣﺘﻐﻴﺮ ﻣﻌﺮف ﺧﻼل آﻞ اﻟﺘﻄﺒﻴﻖ
input box ﺻﻨﺪوق اﻻدﺧﺎل
M=input box (message, title , default)
Solution:
Private sub command1_click
A=val text1)
B= val (text2)
C=val(text3)
If a>b and a>c then
Label .caption="A is biggest"
Else
Label="A is not the biggest"
End if
End sub
1) Dim 3 (2,3)
2) if x>2 then go to 20
3) end if
4) x=cdng(text1)
4) opton exiplicit
5) option base
6) label 1=val(text)
7)
Ex:
Label1=m
R=msg box ("do it again" ,1 ,"example)
If R=VB ok then End sub
If R=VB cancel then End
End sub
ok cancel اوVB ok = رﻗﻢ وﻻ ﻧﻀﻊR اذا آﺎﻧﺖ
R=5 then end
اﻟﻤﺼﻔﻮﻓﺎت )(Array
ﻟﻜﻲ ﻧﺘﺨﻠﺺ ﻣﻦ اﻟﺼﻔﺮ ﻓﻲ اﻟﻤﺼﻔﻮﻓﻪ ﻧﻜﺘﺐ
Option basic
This code will start all the matrix from
)Dim A(5) ,B(4,3
اذا آﺘﺒﺖ داﺧﻞ اﻻﺟﺮاء او ﺗﻜﻮن ﻣﻌﺮﻓﻪ داﺧﻞ اﻻﺟﺮاء ﻓﻘﻂ اذا آﺘﺐ اﻋﻠﻰ
اﻟﻮﺣﺪﻩ اﻟﺘﻲ ﺗﺸﻤﻞ ﻋﺪﻩ اﺟﺮاءات ﺗﻜﻮن ﺧﻼل ﻣﻌﺮﻓﻪ ﺧﻼل
اي آﻞ اﻻﺟﺮاءات ﻟﻬﺎ اﺳﻠﻮب ﺧﺎص ﻟﻠﻜﺘﺎﺑﻪ
اﺳﻠﻮب اﺧﺮ ﻟﻠﻜﺘﺎﺑﻪ)dim A (1 to 5 )(1 to 4 ,1 to 3
Solution:
EX: a list of number from the biggest to the lowest the list is
(1.1, 2 , 3.2 , 4 ,5 ,6 ,7 ,8 ,1 ,2 ,3 ,7 ) print the result on the
form
Private sub command 1 _ click ( )
Dim n as integer , I as integer , J as integer ,K as integer
X=array(1.1 ,2 ,302 ,4 ,5 ,6 ,7 ,8 ,1 ,2 ,3 ,7)
N=12
For I=1 to n-1
For J=I+1 to n
If (J) >= x(I) then
K=x(I)
X(I)=x(J)
X(J)=k
End if
Next J
nextI
for I=1to n
print x(I)
next
End sub
2) Do loop
a) Do while ()ﺷﺮط
ﺟﻤﻞ ﻣﺘﻐﻴﺮﻩ ﺗﻨﻔﺬ ﻋﻨﺪ ﺗﺤﻘﻴﻖ اﻟﺸﺮط
Loop
B ) do until
1 ﺟﻤﻞ ﺗﻨﻔﺬ ﻋﻨﺪ ﺗﺤﻘﻴﻖ اﻟﺸﺮط
Loop
c) do
{
Loop until ()ﺷﺮط
d) do
{
Loop until ()ﺷﺮط
Ex :c=1
Do while c< =4 [4]ﻃﺎﻟﻤﺎ ﻗﻴﻤﻪ اﺿﻐﺮ او ﺗﺴﺎوي
Print c
Loop
C=1
Yes
1 , c+1
2 , 1+1
3
Yes 2+1
4
Yes 3+1
1) for next
2) do loop
b) do until loop
ﻳﺎﺧﺬ اﻟﺸﻜﻞ اﻟﺘﺎﻟﻲ
Do until ()ﺷﺮط
ﺟﻤﻠﻪ ﺗﻨﻔﻴﺬﻳﻪ
Loop
Ex: note
Dim x(3)
For i=1 to 7
X(i)=i^2
Next i
Print i
Ex:
C=1
Do until c > 1000
Print c
C=c+1
Loop
do / loop while
s=1
do
print s
s=s+3
loop while s <= 50
do / loop until
s=1
do
print s
s=s+3
if x> 20 then do exit *ﻋﺒﺎرة اﻟﺨﺮوج اﻟﺸﺮﻃﻲ
loop until s> 50
3) while
ﺗﺎﺧﺬ اﻟﺸﻜﻞ اﻟﺘﺎﻟﻲ
While () ﺷﺮط
ﺟﻤﻞ ﺗﻨﻔﻴﺬﻳﻪ
Wend
Ex:
C=0
While c < 20
C=c+1
Wend
Print c
Note:
d) use timer event so that the program will run to 30 see with an event of
command so that to write through the reaming time.
Private sub command 1_click()
P=30
Debug print p
اﻹﺟﺮاء أﻟﺤﺪﺛﻲ
1) subroutine
2) function
3) sub
1)subroutine
Private sub command1 _click()
Go sub 95 subroutine ﻻﺳﺘﺪﻋﺎء اﻟﺒﺮﻧﺎﻣﺞ اﻟﻔﺮﻋﻲ
{
2) function
Private sub command1 _click()
B= ZI=(x ,z ,b)
.
.
.
End sub
Function ZI(x ,y) ﺗﺤﺪث ﺧﺎرج اﻹﺟﺮاء أﻟﺤﺪﺛﻲ
ZI= x^2+log(x)+x^2/sqr (z)
.
.
.
.
End function
Option explicit
Option base 1
Dim c(5,5) ,a(5,5), I ,j
Private sub command 1 _click()
For I 1 to 5
For j 1 to 5
A(I,J)=MS(I,J)
Next
Next
Go to 10
Call s print (a(), c())
Exit sub
10 for I=1 to 5
For j 1 to 5
C(I,J)=a(I,J)/SQR(J)
Next
Next
return
End sub
Sub s print (a(), c())
For I 1 to 5
For J 1 to 5
Debug .print I,J ,a(I,J), C(I,J)
Next
Next
End sub
If the heat generation inside tissue from the top heat laser beam is q=MIoe-mz
Q=heat generation (w/m3)
Io=2p/πw2
P=power=10w
W o=waist radius= 5*10-4
Z=depth(m)
Design an application so that a scroll bar will change the depth from 1µm
to1000µm and use it in the above equation to find the heat generation in tissue
write in label , use tier to limit the run time to60 sec ,write the remain time to end
the program in asecond label
Solution:
Private sub H scroll _change()
Call heat
End sub
Private sub H scroll _scroll()
Call heat
End sub
Sub heat()
z=Hscroll1.value
Z=z/1 E6 OR Z=Z*1E-6
P=10
µu=98000
Q= µu*p/(3.14*(55-4)^2*exp(-µu*z)
Label="heat generation"&Q
End sub
Sub timer1 _timer()
S=60
X=timer
Do while x +s > timer
Do events
Label 2 ="Remaining time"& x+s -timer
Loop
End
End sub
Ex: Use matrix having 7 rows in the same number of days 1 week an 2 column
,use input box to enter the value of temperature 2 per day for 7 day , each day
have 2 value one for max and the other for min use msg box to write the max
temp of the day at which it a accurse and so for min temp find the average .write
it in immediate window , find the nearest temp to the average and the day at
which it occurs write on the form 0
اﺳﺌﻠﻪ اﻣﺘﺤﺎن؟
Q1 : use command button and three text to design an application showing the
mouse events which are mouse down , mouse up, move write proper sentence in
text box s
Q2: having a value of x=2 a van dine of y input to application from textbox a
value of z input to the application from the input box then use a proper events so
that to start the application that read x , y ,z and input then to the following?
Q3: using a proper events design an application so that to use 2 matrix each of
which have(20,20) dimension the element of the first matrix is no. of row plus no.
of column PLUS 2 use sub to calculate to sum of the matrix an average use
sabtrine to calculate element of matrix no.2 which is equal to the value of
element divide by no. of row use sub to write the no .of row , no. of column value
of matrix , value of matrix no.2 in immediate?
Ex: if the heat generation inside a sub stance from top hat beam can written as
g=µI0e-mz(w/m3)
I0=p/πw02 (w/m2) , p=power in watt=10
W0= width of beam (m)=5*10 ^-4(radius)
-µ=absorption coefficient(m^-1)=9800 tissue
µ =8000 low carbon steel. For far Ir laser design an application use scroll bar to
change the depth from(1-10^3)µm so that to enter the values in the above eq . to
find heat generation and write it in label 1 so that one must know first if the
required calculation is steel or tissue by choosing option button use timer to
write the time and second from the mid of night in label 2 also limit the running
time to 60 sec.
sol:
private sub H-scroll 1 _change()
call heat
end sub
private sub H-scroll 1_scroll()
call heat
end sub
sub heat()
pi =3.145
z=H scroll . value
z=z*1e -6
p=10
if option 1 =true then
µ u= 9800
Io=p/(pi*w^2)
Q= µ u*Io*exp(-µ u*z)
Label 1=" heat generation"&q
Else if option 2 =true
µ u =8000
Io=p/ (pI *w^2)
Q= µ u*Io*exp(-µ u*z)
Label 2="heat generation"&q
End if
End sub
Private sub timer 1_ timer()
S=60
P=timer
Do while s +p> timer
Do events
Label3="remaining timer"& s+p – timer
Loop
End
End sub
Ex: use 2 scroll bar so that to input the value of thickness which is from
(1-100) *10^-6
And second scroll bar to input the value of radius for gassian beam (r,z)
write them in labels input these value to equation
Which model the heat generation inside tissue where for this
wavelength µ=54000m^-1
Io=2p/πWo^2
P=10
W= waist radius =5*10^-4m
Write the result on label , use timer to limit the remaining time to 40 sec ,
use third scroll bar to take the value of the remaining time to end the
program and indicate it on the third scrollbar
Solution:
Private sub H scroll 1_change()
Call heat
End sub
Private sub Hscroll1_scroll()
Call heat
End sub
Private sub Hscroll2_scroll()
Call heat
End sub
Sub heat()
Z=H scroll 1.value
Pi =3.1456
z=z*10 e-6
label 1="r"&r
w=5 e-4
p=10
µu=5400
Io=2*p/(pi*w^2)
Q= µu*Io*exp(-µu*z)*exp(-
2*r^2/w^2)
Label 3="q" &q
End sub
Private sub timer _timer()
S=10
B=timer
Do while s +b > timer
Do events
X= int (b +s-timer)
V scroll .value=x
Loop :end: end sub