تبلیغات
دانشجویان مواد دانشگاه تجن - ویژوال بیسیک - تمرین ها 3
چهارشنبه 1390/11/5

ویژوال بیسیک - تمرین ها 3

• نوشته شده توسط: ArAm

سوالات امتحان ترم 8 صنایع

 

تقسیم از طریق تفریق

Private Sub Command1_Click()

x = Val(Text1)

y = Val(Text2)

i = 0

While x > 0

x = x - y

i = i + 1

Wend

Print i

End Sub


توان رسانی از طریق جمع

Private Sub Command1_Click()

x = Val(Text1)

y = Val(Text2)

f = 1

i = 1

While y >= i

f = f * x

i = i + 1

Wend

Print f

End Sub


به توان رساندن

Private Sub Command1_Click()

Dim a As Integer

Dim b As Integer

a = Val(Text1.Text)

b = Val(Text2.Text)

c = a ^ b

Print c

End Sub


تبدیل سن به سال به معادل هر سال برابر با 30156 * 107

Private Sub Command1_Click()

Dim a As Currency

Dim b As Currency

a = Val(Text1.Text(

b = a * 30156 * 10 ^ 7

Print b

End Sub


مجموع ارقام عددی 5 رقمی

Private Sub Command1_Click()

Dim a As integer

Dim b As integer

a = Val(Text1.Text)

b = a Mod 10

a = a \ 10

b = b + (a Mod 10)

a = a \ 10

b = b + (a Mod 10)

a = a \ 10

b = b + (a Mod 10)

b = b + (a \ 10)

Print b

End Sub


نتیجه ی 4 عمل اصلی

Private Sub Command1_Click()

Dim a As Integer

Dim b As Integer

Dim c As Integer

Dim d As Integer

Dim e As Integer

Dim f As Integer

a = Val(Text1.Text)

b = Val(Text2.Text)

c = a + b

d = a - b

e = a * b

f = a / b

Label1.Caption = Str(c)

Label7.Caption = Str(f)

Label3.Caption = Str(e)

Label5.Caption = Str(d)

End Sub


1

123

12345

123

1

For i = 1 To 5 Step 2

For j = 1 To i

Print j;

Next j

Print

Next i

For i = 3 To 1 Step -2

For j = 1 To i

Print j;

Next j

Print

Next i


1

123

123456

123

1

Print 1;

For i = 0 To 6 Step 3

 For j = 1 To i

 Print j;

 Next j

Print

Next i

For i = 3 To 1 Step -2

For j = 1 To i

Print j;

Next j

Print

Next i


    *

  ***

*****

  ***

  ***

  ***

For i = 1 To 5 Step 2

For k = 2.5 - (i / 2) To 1 Step -1

Print " ";

Next k

For j = 1 To i

Print "*";

Next j

Print

Next i

For i = 1 To 3

For k = 1 To 1

Print " ";

Next k

For j = 1 To 3

Print "*";

Next j

Print

Next i


    *

  ***

*****

  ***   aبه جای   از این دنباله در برنامه اختیاری

  ***             

Private Sub Command1_Click()

For i = 1 To 6 Step 2

 For j = 1 To i

  For k = (i * j) To 3

  Print " ";

  Next k

 Print "*";

 Next j

Print

Next i

Dim a As Integer

a = Val(Text1.Text)

For i = 1 To a

 For j = 1 To 1

  Print " *** ";

 Next j

Print

Next i

End Sub

 


1

2 3

4 5 6

7 8 9 10

11 12 13 14 15

a = 1

b = 1

For i = 1 To 15

Print i;

If ((a - i) Mod b = 0) Then

b = b + 1

Print

a = i

End If

Next i


 تغییر ابعاد و عنوان فرم

Private Sub Command1_Click()

Dim a As Integer

Dim b As Integer

a = Val(Text1.Text)

b = Val(Text2.Text)

Form1.Height = a

Form1.Width = b

Form1.Caption = Text3.Text

End Sub

 

 


نظرات()