Sunteți pe pagina 1din 34

‫‪Visual basic‬‬

‫‪Menu bar‬‬ ‫‪Integrated Development Environment‬‬


‫ﺷﺮﻳﻂ اﻟﻘﺎﺋﻤﺔ‬
‫‪Project explorer‬‬
‫‪Tool bar‬‬ ‫ﻣﺴﺘﻌﺮض اﻟﻤﺸﺮوع‬
‫ﺷﺮﻳﻂ اﻻدوات‬

‫‪Command‬‬ ‫‪Properties windows‬‬


‫زر اﻷواﻣﺮ‬ ‫ﻧﺎﻓﺬة اﻟﺨﺼﺎﺋﺺ‬

‫‪Text box‬‬
‫ﻣﺮﺑﻊ ﻧﺺ‬

‫‪Layout window‬‬

‫‪ Form‬ﺳﺎﺣﺔ اﻟﻌﻤﻞ اﻟﺮﺋﻴﺴﻴﺔ ﻓﻲ ‪VB‬‬

‫ﺑﻴﺌﻪ اﻟﺘﻄﻮﻳﺮ اﻟﻤﺘﻜﺎﻣﻞ )‪(IDE‬‬


‫أي ﺑﺮﻧﺎﻣﺞ ﻳﺪل ﻓﻲ اﻟﻔﻴﺠﻮل ﺑﻴﺴﻚ ﻳﺴﻤﻰ اﻟﺘﻄﺒﻴﻖ‬
‫ﻧﺎﻓﺬة اﻟﺸﻔﺮة‪ :‬هﻲ اﻟﻤﻜﺎن اﻟﺬي ﻳﻜﺘﺐ ﻓﻴﻪ اﻟﺠﻤﻞ اﻟﺒﺮﻣﺠﻴﺔ‬
‫اﻟﺸﻔﺮة‪ :‬هﻲ ﺟﻤﻞ ﺑﺮﻣﺠﻴﻪ ﺗﺆدي وﻇﺎﺋﻒ ﻣﺤﺪودة‬

‫اﻟﺨﻄﻮات اﻻﺳﺎﺳﻴﻪ واﻟﻘﻴﺎﺳﻴﺔ ﻹﻧﺸﺎء اﻟﺘﻄﺒﻴﻖ‬

‫‪ -1‬إﻧﺸﺎء ﻟﻮاﺟﻬﻪ )‪(Form‬‬


‫‪ -2‬وﺿﻊ اﻟﺨﺼﺎﺋﺺ )‪(properties windows‬‬
‫‪ -3‬آﺘﺎﺑﺔ اﻟﺸﻔﺮة)‪(code windows‬‬

‫‪Design time-‬‬
‫)‪(design time‬‬ ‫ﻋﻨﺪ اﻟﺘﻐﻴﺮ ﻳﻜﻮن ﻓﻲ ﻧﺎﻓﺬة اﻟﺨﺼﺎﺋﺺ‬
‫)‪(Run time‬‬ ‫ﻳﻜﻮن اﻟﺘﻐﻴﺮ ﻓﻲ وﻗﺖ اﻟﺘﻨﻔﻴﺬ‬
‫اﻹﺟﺮاء أﻟﺤﺪﺛﻲ)‪(Eevent procedure‬‬
‫‪ -‬اﺳﻄﺮ اﻟﺸﻔﺮة ﻳﺘﻢ ﺗﻨﻔﻴﺬهﺎ ﻋﻨﺪﻣﺎ ﻳﻌﺎﻟﺞ اﻟﻤﺴﺘﺨﺪم آﺎﺋﻨﺎ ﻣﺎ ﻓﻲ اﻟﺒﺮﻧﺎﻣﺞ‬
‫ﺻﻨﺪوق اﻷدوات)‪(tool box‬‬

‫)‪Sub (command1-clicke‬‬
‫{‬
‫‪End sub.‬‬

‫‪Property commmand1.‬‬ ‫‪caption‬‬ ‫"=‬ ‫"‬


‫) اﺳﻢ اﻷداة(‬ ‫‪)value‬اﻟﺨﺎﺻﻴﺔ(‬ ‫)ﻗﻴﻤﺔ(‪value‬‬

‫‪List‬‬ ‫‪add item‬‬ ‫‪check‬‬

‫اﺳﻢ اﻷداة‬ ‫ﻃﺮﻳﻘﻪ‬ ‫اﻟﻘﻴﻤﺔ‬

‫)‪(Rules change the name of object‬‬ ‫ﻗﻮاﻋﺪ أﻟﺘﺴﻤﻴﻪ ﻟﻸدوات‪:‬‬

‫‪a) Name:‬‬

‫‪ -1‬ﻳﺒﺪأ ﺑﺤﺮف‬
‫‪-2‬ﻗﺪ ﻳﻜﻮن اﻻﺳﻢ ﻣﺘﻜﻮن ﻣﻦ ‪ 40‬ﺣﺮف‬
‫‪-3‬ﻻ ﻳﺤﺘﻮي ﻋﻠﻰ اﻹﺷﺎرات اﻟﻤﻮﺟﻮدة ﻓﻲ اﻟﻜﻲ ﺑﻮرد @ ‪$ #‬‬
‫‪-4‬ﻻ ﻳﺠﻮز أن ﻧﺴﻤﻲ اﻷداﺗﻴﻦ ﺑﺎﺳﻢ واﺣﺪ ﻓﻲ اﻟﺘﻄﺒﻴﻖ‬

‫‪b) Location and size‬‬ ‫ﺧﺼﺎﺋﺺ اﻟﻤﻮﻗﻊ واﻟﺤﺠﻢ‬


‫‪top‬‬
‫‪twip=1/20‬‬

‫‪left‬‬ ‫‪height‬‬

‫‪width‬‬
c)Font:

command1.font name="time new roman"

command1.caption="press"

command1.font bold=true
command1.font size=20
‫ﻋﻨﺪ اﻟﺘﻐﻴﺮ ﻓﻲ وﻗﺖ اﻟﺘﻨﻔﻴﺬ ﻳﺠﺐ آﺘﺎﺑﺔ ﺟﻤﻠﻪ ﺑﺮﻣﺠﻴﻪ‬

Text1.text= VB ‫ﻗﺪ ﻳﺄﺗﻲ ﺳﺆال ﻣﺎهﻴﺔ أدوات اﻹدﺧﺎل واﻹﺧﺮاج اﻟﻤﺴﺘﺨﺪﻣﺔ ﻓﻲ‬
"visual basic "
Text1="program"}

Red
green

Text1.back color=VB white blue

black
yellow
Text1.fore color=VB black
‫( ﻟﺘﻐﻴﺮ ﺟﻤﻠﻪ ﺧﺼﺎﺋﺺ ﻓﻲ ان واﺣﺪ‬with text ) ‫ﺗﺴﺘﺨﺪم اﻟﻌﺒﺎرة‬
With text1

.Text="program"

Back color=VBwhite

Fore color =vb black


End with
method
‫ﻃﺮق ﻣﺸﺘﺮآﻪ‬
Label (‫)ﻳﺴﺘﺨﺪم ﻓﻘﻂ ﻟﻺﺧﺮاج إذ ﺗﻮﺟﺪ ﻗﻴﻤﺔ ﻓﻘﻂ‬
1- Move:
: ‫ﻷﺟﻞ ﺗﺤﺮﻳﻚ اﻷداة ﻧﻜﺘﺐ‬
Label1.move 100 ,200, 4000 3000
‫ﻟﺘﻐﻴﺮ‬
‫اﻟﻤﺮاد‬ Label1.left=100
‫ﻳﻌﻨﻲ‬ label1.top=200
‫واﺣﺪ‬ Label1.width=4000
‫ﻣﻨﻬﺎ أو‬
Label1.height=3000
‫اﻟﻤﻌﻄﻰ‬

2) set Focus :
Command1.setfocus

‫ﻟﻨﻘﻞ اﻟﺘﺮآﻴﺰ ﻟﻸداة اﻟﻤﻌﻨﻴﺔ‬

3)command1.zorder 0 ‫ﻓﻮق ﺟﻤﻴﻊ اﻷدوات‬

command1.zorder 1 ‫ﺗﺤﺖ ﺟﻤﻴﻊ اﻷدوات‬

‫اآﺘﺐ ﺗﻄﺒﻴﻖ ﻟﻔﻴﺠﻮال ﺑﻴﺴﻚ ﺑﺎﺳﺘﺨﺪام إﺟﺮاء ﺣﺪﺛﻲ ﻟﻠﺒﺮﻧﺎﻣﺞ‬

Write vb application that using haven't procedure for command and


button to write form caption of example and has location of
100,200,9000,4000 for the left, top, width, height respectively use a text
box with text of "visual basic" in bold ,size18,font name "time new roman
"and move it in run time to200,300,8000,2000,for the left ,top, width&
height ,green back color ,black fore color set the focus on command
button at(design time ,run time) it is assumed that the command button
caption in the design time is "ok" and form caption at the run time is "Ex"
also" the word "application's used as infinitude word the appear at run
time
Solution:-
form inter face:‫ إﻧﺸﺎء اﻟﻮاﺟﻬﺔ‬-1

Text box form


command

change properties:‫ ﺗﻐﻴﺮ اﻟﺨﺼﺎﺋﺺ‬-2

‫اﻷداة‬ ‫اﻟﺨﺎﺻﻴﺔ‬ ‫اﻹﻋﺪاد‬

object property setting


Form caption example
Text Text Visual basic
Text Font bold True
Font size 18
Font name Time new roman
Command1 Set focus True
Command1 Caption ok

code:‫ آﺘﺎﺑﺔ اﻟﺸﻔﺮة‬-3

Private sub command1_click( )


form1.move 200,300,8000,2000
With text1
.back color=VB green
.fore color=VB black
.font size=20
.font name="verdantly"
.text="application"
End with

3) command events ‫اﻻﺣﺪاث اﻟﻤﺸﺘﺮآﻪ‬


command button

‫اﻻﺳﻢ اﻻﻓﺘﺮاﺿﻲ‬
command1,command2
private sub command1_click()
{
End sub

a)mouse event
click ‫ﻧﻘﺮ‬
DB click ‫ﻧﻘﺮ ﻣﺰدوج‬
mouse move ‫ﺣﺮآﻪ اﻟﻤﺎوس‬
mouse down ‫ﺣﺮآﻪ اﻟﻤﺎوس إﻟﻰ اﻷﺳﻔﻞ‬
mouse up ‫ﺣﺮآﻪ اﻟﻤﺎوس إﻟﻰ اﻷﻋﻠﻰ‬

Private sub command1_mouse down(Button as integer-Shift as integer-X as


single-Y as single)
{
End sub

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

Command1 Mouse down

Private sub command _mouse down(Button As integer, shift As integer ,x As


single, YAs single)
If button=1 then
Text1="left Button of mouse is down"
Else if Button=2 then
Text1.text="Right Button of mouse down"
Else if Button=4 then
Text1.text="middle Button of mouse down"
End if
End sub
Private sub command1_ mouse move(Button As integer , shift As integer , xAs
single ,y As single)
If shift=1 then
Text3="move"
Text3="shift mouse down"
End if
End sub

(key board events) ‫إﺣﺪاث ﻟﻮﺣﻪ اﻟﻤﻔﺎﺗﻴﺢ‬


We will 3 type of events on key board
( key press) ‫اﻟﻨﻘﺮ ﻋﻠﻰ أي زر ﻓﻲ ﻟﻮﺣﺔ اﻟﻤﻔﺎﺗﻴﺢ‬
(key down) ‫اﻟﻀﻐﻂ ﻋﻠﻰ أي زر ﻓﻲ ﻟﻮﺣﺔ اﻟﻤﻔﺎﺗﻴﺢ‬
(key up ) (‫ﺗﺤﺮﻳﺮ اﻟﺰر )ﻋﺎدة ﻳﺴﺒﻘﻪ ﺣﺚ اﻟﻀﻐﻂ‬
Private sub command1_key down(key code as integer, shift as integer)
End sub
Private sub command1_key press(key ascii as integer)
(ascii) ‫ﻳﻤﻜﻦ أن ﻳﺴﺎوي ﻗﻴﻤﻪ ﻣﻘﺎﺑﻠﻪ ﻟﻠﻤﻔﺎﺗﻴﺢ آﻤﺎ ﻳﻌﺮف ﻓﻲ ﻣﻘﻴﺎس‬
‫وﺣﺴﺐ اﻻﺳﺘﺨﺪام ﻻﺣﻆ ﻓﻲ اﻟﺠﺪول‬
Key ascii
A 65
a 67
‫ﻣﺜﺎل ﻳﺒﻴﻦ أﺣﺪاث ﻟﻮﺣﺔ اﻟﻤﻔﺎﺗﻴﺢ‬
‫ﻣﻬﻢ‬ Design An application in VB that use the key board events which are:
1) key press
2)key up
3) key down
With text box
To show the suitable word at each events use R whose its ascii code is 82 for 2
and 3 events
1)design form

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‬‬

‫‪6) Change‬‬ ‫ﻳﺤﺪث ﺑﻤﺠﺮد ﺗﻐﻴﺮ ﻣﺤﺘﻮﻳﺎت اﻷداة آﺎﻟﻨﺺ أو اﻟﺨﺎﺻﻴﺔ‬


‫) ‪(initialize‬‬ ‫اﺳﺘﺨﺪام اﻟﻨﻤﻮذج ﻓﻲ اﻟﺸﻔﺮة‬
‫)‪(Resize‬‬ ‫ﺗﻐﻴﺮ ﺣﺠﻢ اﻟﻨﻤﻮذج‬
‫)‪(Activate‬‬ ‫ﻳﺤﺚ ﺑﻌﺪ اﻟﺤﺚ ) ‪ (Resize‬ﻣﺒﺎﺷﺮة‬
‫‪(Paint‬‬ ‫إﻋﺎدة رﺳﻢ اﻟﻨﺎﻓﺬة ﺑﻌﺪ إﺧﻔﺎءهﺎ‬
‫)‪(Deactivate‬‬ ‫ﻋﻜﺲ ‪Activate‬‬
‫)‪(Query load‬‬ ‫اﻟﻨﺎﻓﺬة ﻋﻠﻰ وﺷﻚ اﻻزاﻟﻪ أﻟﻨﻬﺎﺋﻴﻪ ﻣﻦ أﻟﺬاآﺮﻩ وﻟﻴﺲ اﻹﺧﻔﺎء اﻟﻤﺆﻗﺖ‬
‫)‪( Unload‬‬ ‫ﺗﻨﻬﻲ اﻟﻌﻤﻞ ﻋﻠﻰ اﻟﻨﻤﻮذج‬
‫) ‪(Terminate‬‬ ‫اﻹﻧﻬﺎء اﻟﺘﺎم ﻟﻮﺟﻮد اﻟﻨﻤﻮذج ﻓﻲ اﻟﺘﻄﺒﻴﻖ‬
‫)‪(Load‬‬ ‫ﻳﺤﺪث ﺑﻤﺠﺮد ﺗﺤﻤﻴﻞ آﺎﺋﻦ اﻟﻨﻤﻮذج ﻓﻲ اﻟﺘﻄﺒﻴﻖ ﻳﺤﺪث اﻟﻴﺎ‬

‫)(‪Private sub form _load‬‬


‫"‪Text1="visual basic‬‬
‫‪End sub‬‬

‫)(‪Private sub form _Resize‬‬


‫‪Form. Move 200 ,300, 5000 ,8000‬‬
‫‪Text .move 100 ,100 ,5000 ,7000‬‬
‫‪End sub‬‬

‫ﻋﻨﺪﻣﺎ ﻳﻜﻮن اﻟﻤﻄﻠﻮب إﻧﻬﺎء اﻟﻌﻤﻞ ﻋﻠﻰ اﻟﻨﻤﻮذج ﻧﻜﺘﺐ‬


‫‪Unloadform1.‬‬

‫)‪(Hide‬‬ ‫ﻹﺧﻔﺎء اﻟﻨﻤﻮذج وهﻮ ﻇﺎهﺮ هﻲ‬


‫)‪(Show‬‬ ‫ﻹﻇﻬﺎر اﻟﻨﻤﻮذج وهﻮ ﻣﺨﻔﻲ‬
‫اﻹﻋﻼن ﻋﻦ اﻟﺜﻮاﺑﺖ )‪(constant‬‬
‫‪Option explicit‬‬
‫‪dim‬‬
‫‪constant pi as single=3.14619 ,h=5.667E-8‬‬

‫اﻟﻌﻮاﻣﻞ أﻟﺮﻳﺎﺿﻴﻪ اﻻﺳﺎﺳﻴﻪ‬


‫^‪+ ,- ,* ,/ ,‬‬ ‫أذا ﻟﻢ ﻳﻜﺘﺐ ﻓﻴﻪ ﺷﺊ ﻓﻬﻮ‬
‫‪Z=x+y‬‬ ‫‪ public‬وإذا ﻳﻮﺟﺪ ﺷﺊ‬
‫‪Z=x-y‬‬ ‫ﻓﻬﻮ أﺳﻠﻮب ‪cont‬‬
‫‪Z=x*y‬‬
‫‪Z=x/y‬‬

‫‪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‬‬

‫‪tanx -1‬‬ ‫)‪atan(x‬‬


‫‪ex‬‬ ‫)‪Exp(x‬‬
‫)‪Sqrt(x‬‬
‫)‪ sign(x) (-‬ﻋﻼﻣﺔ ﻣﺘﻐﻴﺮ ‪x‬‬
‫ﻟﺘﺤﻮﻳﻞ اﻟﻤﺘﻐﻴﺮ ) ‪ (x‬إﻟﻰ رﻗﻢ ﻗﺎﺑﻞ ﻟﻺﺟﺮاء اﻟﺤﺴﺎﺑﺎت ﻋﻠﻴﻪ )‪val(x‬‬
‫)‪log(x‬‬ ‫‪Lux‬‬
‫دوال ﻟﺘﺤﻮﻳﻞ اﻟﺒﻴﺎﻧﺎت‬
‫‪CDBL‬‬ ‫إﻟﻰ دﻗﻪ ﻣﻀﺎﻋﻔﻪ‬
‫‪Cint‬‬ ‫إﻟﻰ ﻋﺪد ﺻﺤﻴﺢ‬
‫‪C lng‬‬ ‫إﻟﻰ ﻋﺪد ﺻﺤﻴﺢ ﻃﻮﻳﻞ‬
‫‪Csng‬‬ ‫إﻟﻰ ﺻﻔﻪ اﻋﺘﻴﺎدﻳﺔ‬
‫‪Cstr‬‬ ‫إﻟﻰ ﻧﺺ‬
‫‪Cvar‬‬ ‫إﻟﻰ ﻣﺴﺘﻮى‬
‫ﺣﻮل ﻣﻦ دﻗﻪ اﻋﺘﻴﺎدﻳﺔ إﻟﻰ دﻗﻪ ﻣﻀﺎﻋﻔﻪ اﺳﻤﻪ‪ x‬وﺿﻌﻪ ﻓﻲ ﻣﺘﻐﻴﺮ اﺳﻤﻪ ‪y‬‬
‫‪EX:‬‬
‫‪X=10+15*2/4^2‬‬
‫‪=10+15*2/16‬‬
‫‪=10+‬‬
‫‪10+18‬‬ ‫‪11.8‬‬
‫‪R=1+2^3/4‬‬
‫‪=1+8/4‬‬
‫‪=1+2 3‬‬
‫اﻷﻗﻮاس ﺗﺘﺤﻜﻢ ﻓﻲ ﺳﻴﺮ اﻟﻌﻤﻠﻴﺎت‬
‫‪N3= ((8-5)*3)^2-(3*3)^2-81‬‬
‫‪=81-81-81‬‬
‫‪= -81‬‬
EX: TRANSFORMATION OF MATHMATICAL
EQUATION TO CODE:-

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:-

private sub command1_click()


y=val (text1.text)
x=input box ("Example ","value of x", Go)
X=X*3.1415/180
Z=3.73
M=((COS(X)+SIN(X)/EXP(X)+ATN(X)/Y+LOG(X)/Z/SQRT(Z^
2+Yp^(Z-X))
X2=msg box(ms ,"button ,title)
If x2=VB yes
if x2=7 then
x2=7 yes ‫ﻧﻄﺒﻖ اﻟﺸﺊ اﻟﺬي ﻧﺮﻳﺪﻩ‬
X2=6 No
(input box ) ‫ﻓﻲ ﻣﺮﺑﻊ اﻹدﺧﺎل‬
0 Ok
1 Ok, cancel
2 Abort, retry, ignore
4 No ,yes
16 Stop(8)
32 ?
48 !
64 Information sign
Response:

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

‫ﺷﺮوط اﻧﻮاع اﻟﺒﻴﺎﻧﺎت‬


‫ﻳﺠﺐ ﺗﺤﺪﻳﺪ ﻧﻮع اﻟﺒﻴﺎن ﻋﻨﺪ اﺳﺘﺨﺪام ﺗﻄﺒﻴﻘﺎت ﻓﻲ اﻟﻔﻴﺠﻮل ﺑﻴﺴﻚ وذﻟﻚ ﻟﺤﺠﺰ ﻣﺴﺎﻓﻪ اﻻزﻣﻪ ﻓﻘﻂ‬
‫ﻟﻠﺘﻄﺒﻴﻴﻖ‬
# +-1017,7*10 8byte double

‫ﻗﺪ ﻳﺎﺗﻲ ﺑﺎﻟﺴﺆال ﻣﺎ ﻣﻌﻨﻰ رﻣﺰ ﻣﻦ اﻟﺮﻣﻮز اﻋﻼﻩ ﻓﻨﻜﺘﺐ وﻣﻌﻨﺎﻩ هﻜﺬا‬
% 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‬‬

‫ﺗﺴﺘﺨﺪم )‪(-‬ﻓﺮاغ ﻟﺮﺑﻂ ﺑﻴﻦ ﺳﻄﺮﻳﻴﻦ ﺑﺠﻤﻠﻪ ﺑﺮﻣﺠﻴﻪ واﺣﺪﻩ‬


‫…‪ʘ this program is used to calculate‬‬

‫‪comment‬‬ ‫ﺗﺴﺘﺨﺪم ﻟﻼﻋﻼن ﻋﻦ ﺟﻤﻞ اﻟﺘﻌﻠﻴﻖ‬

‫‪Rules of naming procedure, variable , and constant‬‬


‫اﻻﺳﻢ ﻻ ﻳﺒﺪا ﺑﺮﻗﻢ‬
‫ﻣﻦ اﻟﻤﺮآﺰ ﻳﻤﺘﺪ إﻟﻰ ) ‪ 256‬ﺣﺮف او رﻗﻢ(‬
‫ﻻ ﻳﺤﺘﻮي ﻋﻠﻰ رﻣﺰ و ﺗﻌﺮﻳﻒ ‪! $،# ،‬‬
‫(‬ ‫ﻟﺘﺠﻨﺐ اﺧﺘﻴﺎر اﻟﺘﻌﺎﺑﻴﺮ اﻟﻤﺸﺎﺑﻬﻪ ﻟﻞ )‬
‫)‪(variable‬‬ ‫اﻻﻋﻼن ﻋﻦ اﻟﻤﺘﻐﻴﺮات‬
‫)اﻻﻋﻼن اﻟﺪاﺧﻠﻲ (‬ ‫‪Implicit‬‬
‫ﻓﻲ ﺣﺎﻟﻪ ﻋﺪم اﻋﻄﺎء ﻗﻴﻤﻪ ل ‪ X‬ﻓﻤﻬﻨﺎهﺎ ‪X=0‬‬
‫‪X=x+1‬‬
‫ﻓﻴﺮﺟﻊ ﻓﻴﻜﻮن اﻟﻨﺎﺗﺞ‪ loop‬وﻗﺪ ﻳﺤﺘﻮي ﻋﻠﻰ اآﺜﺮ ﻣﻦ‬
‫‪Explicit‬اﻻﻋﻼن اﻟﺨﺎرﺟﻲ‬
‫اول ﺷﺊ ﻳﻜﺘﺐ ﻓﻲ اﻻﻋﻼن اﻟﺨﺎرﺟﻲ‬ ‫‪option explicit‬‬
‫ﻳﺴﺘﺨﺪﻣﻬﺎ اﻟﻤﺒﺮﻣﺠﻮن ﻟﺘﺠﻨﺐ اﻻﺧﻄﺎء ﻓﻲ آﺘﺎﺑﺔ اﻟﻤﺘﻐﻴﺮات‬

‫ﺟﻤﻠﻪ اﻻﻋﻼن اﻟﺨﺎرﺟﻲ‪To explicit declaration of variables‬‬


‫ﺣﺮف ‪x.ʘ‬‬
‫رﻗﻢ ‪x.ʘ‬‬
dim(‫)اﺳﻢ اﻟﻤﺘﻐﻴﺮ‬AS(‫)ﻧﻮع اﻟﺒﻴﺎن‬
x y ‫ﻟﻠﻼﻋﻼن ﻋﻦ ﻣﺘﻐﻴﺮ اﺳﻤﻪ‬
Dim xy

Option explicit
public x y ‫ﻻﻳﺠﻮز آﺘﺎﺑﻪ‬
‫ ﻳﺼﺢ آﺘﺎﺑﺘﻬﺎ داﺧﻞ وﺧﺎرج اﻻﺟﺮاء‬dim ‫ﻟﻜﻦ‬
public x y‫آﻴﻒ ﺗﻌﻠﻦ ﻋﻦ ﻣﺘﻐﻴﺮ ﻣﻌﺮف ﺧﻼل آﻞ اﻟﺘﻄﺒﻴﻖ‬
input box ‫ﺻﻨﺪوق اﻻدﺧﺎل‬
M=input box (message, title , default)

Ex :use command button so that when click on


message it the message it application will use input box
to write the input value such as number 2 on form
Solution:
Private sub command _click ( )
Message="inter value"
Title="example input box"
Default="2"
X=input box (message ,title , default)
‫ﻗﺒﻞ آﻞ ﺷﺊ واﻻ ﺗﻜﻮن ﻧﺘﻴﺠﻪ اﻟﺒﺮﻧﺎﻣﺞ ﻓﺎرﻏﻪ‬
Print x
End sub
Msg box "x1 ,button ,"title"
0 → ok
1 → Ok cancel
2 → Abort retry ignore
yes → 7 ‫ﻧﻈﻐﻂ ﻋﻠﻰ‬
No → 6
Private sub cheked2_click
If check2.value =VB checked then
Text1.font italic= true
Else
Text1.font italic=false
End if
End sub
Private sub option1_ click( )
If option1=true then text1.font name="time new roman"
End sub
Private sub option2_click( )
If option2= true then
Text1.font name="verdane"
End if
End sub
if ( ) then

←‫ = اﻟﻌﻼﻣﻪ اﻟﺮﻳﺎﺿﻴﻪ اﺗﺠﺎهﻬﺎ‬,> ,< ,<= ,< >

Y=B2+X X=2 a>3


Y=B+X X=3 a=3
Y=1/B+X X=4 a<3
Solution:
If a >3 and x=2 then y=b^2+x
If a=3 and x=3 then y=b +x
If a<3 an x=4 then y=1/b+x
and ‫ ﻳﺘﻄﻠﺐ ﺗﺤﻘﻴﻖ اﻟﺸﺮﻃﻴﻦ‬or , and ‫اﻟﺸﺮط اﻟﻤﺮآﺐ ﻳﺤﺘﻮي ﻋﻠﻰ‬
or ‫ﻳﻌﺘﺒﺮ اﻟﺸﺮط اﻟﻤﺮآﺐ ﻣﺘﺤﻘﻘﺎ وﻳﺘﻄﻠﺐ ﺗﺤﻘﻴﻖ اﻟﺸﺮط واﺣﺪ ﻓﻲ‬
‫وﻳﻌﺘﺒﺮ اﻟﺸﺮط اﻟﻤﺮآﺐ ﻣﺘﺤﻘﻘﺎ‬
Ex :use 3 text box to show that the number that exist
greater than that which exist in text2 and greater than
exist in text3 write the result in label?

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

Example: say if the code is true or false

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) 

Its code is x=y^2+cos(z)/2*log(y)


8) Z=msg box(masg, little,button)
9) Y=input box(msg ,title ,default)
10) Const xz as single=5.231

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‬‬

‫‪if statement‬‬ ‫ﺗﺴﺘﺨﺪم ﻟﻠﺘﺤﻜﻢ ﻓﻲ ﺳﻴﺮ اﻟﻌﻤﺎﻳﺎت‬


‫داﺧﻞ اﻟﺘﻄﺒﻴﻖ وهﻲ ﻋﻠﻰ ﻋﺪة اﻧﻮاع‬
‫‪if‬‬ ‫) ﺷﺮط (‬ ‫ﺟﻤﻠﻪ ﺗﻨﻔﻴﺬﻳﻪ ‪then‬‬
‫ﺟﻤﻠﻪ ﺗﻨﻔﻴﺬﻳﻪ ﺗﻨﻔﺬ ﻋﻨﺪ ﺗﺤﻘﻴﻖ اﻟﺸﺮط ‪if ( ) then‬‬
‫ﺟﻤﻠﻪ ﺗﻨﻔﻴﺬﻳﻪ ﺗﻨﻔﺬ ﻋﻨﺪ ﻋﺪم ﺗﺤﻘﻴﻖ اﻟﺸﺮط ‪Else 1‬‬
‫‪End if‬‬
‫ﺟﻤﻠﻪ ﺗﻨﻔﺬ ﻋﻨﺪ ﺗﺤﻘﻴﻖ اﻟﺸﺮط ‪ ) then‬ﺷﺮط‪if( 1‬‬
‫‪Else if‬‬ ‫ﺟﻤﻠﻪ ﺗﻨﻔﺬ ﻋﻨﺪ ﺗﺤﻘﻴﻖ ﺷﺮط‪2‬‬
‫ﺟﻤﻠﻪ ﺗﻨﻔﺬ ﻋﻨﺪ ﻋﺪم ﺗﺤﻘﻴﻖ ﺷﺮط‪ 1‬وﺷﺮط ‪Else 2‬‬
‫‪End if‬‬
‫) ﺷﺮط ( ‪if‬‬ ‫ﺟﻤﻠﻪ ﺗﻨﻔﺬ ﻋﻨﺪ ﺗﺤﻘﻴﻖ ﺷﺮط ‪then‬‬
‫‪End if‬‬
‫اﺳﻢ اﻓﺘﺮاﺿﻲ‬ ‫اﻻداة‬
‫‪Check box‬‬
‫ﻋﻨﺪ اﺳﺘﻌﻤﺎل اﻻداة ‪ check‬ﻳﻮﺿﻊ ﻋﻼﻣﻪ )ﺻﺢ( داﺧﻞ اﻟﻤﺮﺑﻊ‬
‫‪VB checked=1‬‬
‫=‪VB checked‬‬
‫=‪VB checked‬‬
‫‪VB checked =1ʘ‬‬
EX: use text box &2 option button & 2 check box
To write a string of "visual basic6"in text box
Use the 2 option button to select the name of the font which
is either "time new roman"&"verdana" use the 2 check box
to select that the font is italic or not and the second check
box to select that the font is bold or not. Initially let the font
size 14 fore color is red , back color is black. Font name is
"Tahoma".

Private sub form_ load( )


With text
.text="visual basic"
.font size=14
.fore color=VB Red
.back color=VB Black
.font name="Tahoma"
End with
End sub
Private sub check1_ click( )
If check 1.value=VB checked then
Text1.font bold=true
End if
End sub
EX :use 2 command button one to write time for running the
program (20 sec)and the second for using the message box
yes to start a timer for 20second after which write a
message box to write time stop to run another events
(command1) other wise the program is term method ?

Private sub command2_ click( )


D=20
Debug. Print p
End sub
Private sub command1 _ click ( )
M= msgbox("press" , 4 ,"try")
If m= 6 then
If m= VB yes then
P=20
S=timer
Do while timer < s +p
Do events
Loop]
7. Condition statement "‫"اﻟﺠﻤﻞ اﻟﺸﺮﻃﻴﻪ‬
7.1 if then
7.2 select case
-:‫ﺗﺴﺘﺨﺪم ﻋﻨﺪﻣﺎ ﻳﻜﻮن ﺗﻨﻔﻴﺬ ﻣﺠﻤﻮﻋﻪ ﺟﻤﻞ ﻳﻌﺘﻤﺪ ﻋﻠﻰ ﻗﻴﻤﺔ ﻣﺘﻐﻴﺮ واﺣﺪ وﺗﺎﺧﺬ اﻟﺸﻜﻞ اﻟﺘﺎﻟﻲ‬
Select case( test value)
variable , ) ‫ﻳﻤﻜﻦ ان ﻳﻜﻮن اﻟﻤﺘﻐﻴﺮ ﺳﻠﺴﻠﻪ ﻧﺼﻴﻪ‬
( string
Case ( value 1)
{
Case (value2)
{
End select

EX:- design an application to enter the degree at a student


from a text box and test this value so that using select case
, show the result on message box

Solution:

Text box form


command

Private sub command1 _ click ( )


X=value (text)
Select case x
Case 90 to 100
Msg box "Exc."
Case 80 to 89
Msg box: "v. Good"
Case 70 to 79
Msg box "Good"
Case 60 to 69
Msg box "med"
Case 50 to59
Msgbox "pass"
Case 40 to 49
Msg box "fail"
Case else
Msgbox "Error"
End select
End sub
8. loop's
8.1 for next
for ‫ ) اﻟﻘﻴﻤﻪ اﻻﺑﺘﺪاﺋﻴﻪ(= اﺳﻢ اﻟﻌﺪد‬to (‫)اﻟﻘﻴﻤﻪ اﻟﻨﻬﺎﺋﻴﻪ‬ [ Step ( no)]
‫ﺟﻤﻞ ﺗﻨﻔﻴﺬﻳﻪ ﺗﺎﺧﺬ ﻗﻴﻢ اﻟﺘﻐﻴﺮ ﻓﻲ اﻟﻌﺪﻟﺪ‬
Next [ ‫]اﺳﻢ اﻟﻌﺪد‬
For i= 1 to 10 step 3
X= i+1 i=1 ,x=2
Print x
Next
Point on form 2
I=4 , x=5
I=7 , x=8
I=10 ,x=11

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:

  ‫ﻻﻳﺠﻮز ﺗﺪاﺧﻞ اﻟﺪورات‬ .1


  ‫اﻣﻜﺎﻧﻴﻪ اﻻﻧﻬﺎء‬ .2
  do‐loop ‫ ﻟﻠﺨﺮوج اﻟﺸﺮﻃﻲ ﻣﻦ دورﻩ‬Do exit .3
  for next ‫ ﻟﻠﺨﺮوج اﻟﺸﺮﻃﻲ ﻣﻦ‬Exit for .4
  ‫ﻻﻳﺠﻮز اﻟﻘﻔﺰ ﻣﻦ داﺧﻞ اﻟﺪورﻩ اﻟﻰ ﺧﺎرﺟﻬﺎ‬ .5
  next j ‫ ﻗﺒﻞ‬next i ‫ﻻﻳﺠﻮز آﺘﺎﺑﻪ‬ .6
For i=1 to 5
For j=1 to 3
X(I,j)=i^2
Next j
Next i
if x> 2 then exit for ‫ﻋﺒﺎرﻩ اﻟﺨﺮوج اﻟﺸﺮﻃﻲ‬

immediate window (‫)ﻧﺎﻓﺬﻩ اﻻواﻣﺮ‬


  1`)use to write result  as we write the following
code ‫ﻟﻜﺘﺎﺑﻪ اﻟﻨﺘﺎﺋﺞ ﻋﻠﻰ ﻧﺎﻓﺬﻩ اﻻواﻣﺮ‬
debug.print (‫اﻟﻤﺮاد آﺘﺎﺑﻪ ﻗﻴﻤﻪ ﻋﻠﻰ اﻟﻨﺎﻓﺬﻩ )اﺳﻢ اﻟﻤﺘﻐﻴﺮ‬
2)to test same simple ‫ﺑﺴﻴﻄﻪ ﻻﺟﻞ اﻻﺧﺘﻴﺎر‬ ‫ﻧﺨﺘﺎر ﺟﻤﻠﻪ ﺑﺮﻣﺠﻴﻪ‬
‫ﻧﻌﻨﻲ ﺑﻬﺎ ﺛﺎﻧﻴﻪ واﺣﺪﻩ‬
  Interval=1000ms 

time ‫ﻳﺎﺧﺬ ﻣﻦ ﺳﺎﻋﻪ اﻟﺤﺎﺳﺒﻪ‬


timer ‫ﻋﺪد اﻟﺜﻮاﻧﻲ ﻣﻨﺘﺼﻒ اﻟﻠﻴﻞ‬
(‫)اي ﻣﻦ ﺑﺪاﻳﻪ ﻳﻮم ﺟﺪﻳﺪ‬
Ex:using timer event to set the timer interval to (1 sec) also use labels one to
show time and second form the mid of night
Private sub form-load()
Timer1.interval=1000
End sub
Private sub timer1.timer()
Label1.caption=time
Label2.caption=timer
End sub
F= timer
Msg box("pause for"& of f-s&"second")
Else
End
End if
End sub
‫اآﺘﺐ ﺑﺮﻧﺎﻣﺞ ﻳﺒﻴﻦ آﻢ اﻟﻮﻗﺖ اﻟﺒﺎﻗﻲ؟‬
Private sub command2 _click()
Print abs(p +s- timer)
End sub
‫اﺳﺌﻠﻪ اﻣﺘﺤﺎن‬
Q1) design an application to see if the student is pass or not assume the degree is
form 100 if the degree > 50 then write pass in a massage box other write fail in a
message box use select case
a) for i=2 to 10
x=x+1
next i
b)i=1
do while I<=4
i=i+1
c) complete or not
for i=1 to 10
for j=2 to 30
a(I,J)=i^2
next i
Next j

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 ‫ﻻﺳﺘﺪﻋﺎء اﻟﺒﺮﻧﺎﻣﺞ اﻟﻔﺮﻋﻲ‬
{

exit sub …………………………. ‫ﻟﺘﺠﻨﺐ اﻟﺪﺧﻮل ﻏﻴﺮ اﻟﻤﺴﻴﻄﺮ ﻋﻠﻴﻪ‬


return ……………………………………….‫ﻋﺒﺎرة أﻟﻌﻮدﻩ إﻟﻰ اﻹﺟﺮاء أﻟﺤﺪﺛﻲ اﻟﺬي اﺳﺘﺪﻋﺎﻩ‬
subroutine ‫أل‬
end sub ………………………..‫ﻧﻬﺎﻳﺔ اﻹﺟﺮاء أﻟﺤﺪﺛﻲ‬

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

3) Sub ‫اﻹﺟﺮاء اﻟﻌﺎم‬


Private sub command1 _click()
call(Xo , Y o , Z()) ‫آﻴﻔﻴﻪ اﺳﺘﺪﻋﺎء هﺬا‬
‫اﻟﺒﺮﻧﺎﻣﺞ ﻟﻺﺟﺮاء اﻟﻌﺎم‬
End sub
] sub d(x, y ,z) x as int y ‫ﻟﻮ أراد ﺗﺒﻴﺎﻧﻬﺎ ﻟﻜﺘﺒﻨﺎ‬
x=y +z ‫ﻣﺘﻐﻴﺮ واﺣﺪ‬
End sub
‫ﻋﻦ اﻹﺟﺮاء اﻟﻌﺎم‬
Ex:
Private sub command1_click()
Dim x(8) ,y(8) ,z(8)
Call sub d( x() ,y() ,z())
End sub
sub d(x(), y(), z()) ‫إﺟﺮاء ﻋﺎم ﺧﺎرج اﻹﺟﺮاء أﻟﺤﺪﺛﻲ‬
For I=1 to 8
Z(I)=x(I)+y(I)
Next
Exit sub ‫ﻋﻨﺪ أﻟﺤﺎﺟﻪ اﻟﺨﺮوج ﻣﻦ اﻹﺟﺮاء أﻟﺤﺪﺛﻲ‬
End sub
function ‫ ﻟﻜﻦ ﻻ ﺗﺴﺘﺨﺪم ﻓﻲ أل‬subroutine ‫ و‬sub ‫ﺗﺴﺘﺨﺪم ﻓﻘﻂ ﻓﻲ‬
Write proper event to use two matrices so that use function to define the
elements of the first matrix which is equal to the sum of number or no. of row
and number of column plus 1, then use subroutine to divide the value of element
by square root of column so that put the result in another matrix with the same
dimension as(5*5) after that asub to write no. of row , no . of column , value of
old and new matrix in immediate window.

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

1 ‫ﻧﺠﻌﻞ اﻟﻤﺼﻔﻮﻓﺔ ﺗﺒﺪأ ﻣﻦ‬


Option Base 1
Private sub command 1 _ click()
Dim day ul (7,2)
Day=array("sat" ,"sun" ,"mon" ,"tus" ,"wen", "thu" , "fri")
For i=1 to 7
For j=1 to 2
Day u (I ,j)=input box("enter temp")
Next
Next
Max s=day u(1,1)
K=1
For i=1 to 7
For j=1 to 2
If day u (I ,j) >max s then
Max s = day u (I,j)
K= I
End if
Next i
Next j
Msg box("max temp is" & max s &"at of day (k)
So m=0
For i=1 to 7
For j=1 to 2
Sum =sum +day ul (I ,j)
Next: next
Av=sum/4
Debug .print "ave temp"& av
Md =abs=(day ul (1,1)-av)
K=1:s=1
For i=1 to 7
For j=1 to 2
If abs (day ul(I ,j)-av < md then
Md =abs (day ul (I,j) - av)
K=i:s=j
End if
Next: next
Print day ul(k,s)-day(k)
End sub
Ex: if MN is a 2 dimensions matrix (20, 20), the value of each element is equal
to the sum of number or no. of column divide by 10 , use function to determine
the value , use sub to do the following
Changing the diagnose of the matrix
Find the sum of each row and the sum of each column
Find the maximum and min .value of write the result in immediate the window ,
use proper event to sort the programs?
Solution:
Option base 1
Dim MN(20, 20)
Private sub command 1 _click()
For I 1 to 20
For j 1 to 20
Mn (I,j)=vx(I,j)
Next : next
Call inter change(MN())
Sub inter change (MN())
Dim a(20),b(20)
For I 1 to 20
For j 1 to 20
If i=j then a(i)=MN(I,j)
If I +j=21 then b( I )=MN(I ,j)
Next: next
For I 1 to 20
For j 1 to 20
If I =j the n MN (I,j)=b(i)
If i+j=21 then MN (I,j)=a(i)
Next :next
End sub
Function vx (I ,j)
V x=(I,j)/10
End function
Sub sum of r(MN())
For i=1 to 20
Sum=0
For j=1 to 20
Sum =sum +MN(I,j)
Next
Debug . Print I , sum
Next
For I 1 to 20
Sum=0
For j=1 to 20
Sum = sum +MN (j,i)
Next
Debug. Print I ,sum
Next
End sub
Call max min (MN())
End sub
Sub max min(MN ())
Max s=MN(1,1)
For i= 1to 20
For j 1 to 20
If MN(I,j)> max s then
Max s ==MN(I ,j)
End if
Next :next
Debug . Print "max"&max s
Min=MN(1,1)
For i=1 to 20
For j 1 to 20
If MN (I ,j)< min then
Min=MN(I ,j)
End if
End sub

‫اﺳﺌﻠﻪ اﻣﺘﺤﺎن؟‬

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

S-ar putea să vă placă și