کد برنامه ای که دو عدد را بگیرد و عدد اولی را به توان دیگری برساند
من یک سوال داشتم
سوال من اینه که میخوام یک برنامه برام بنویسید که دو عدد را بگیرد و عدد اولی را به توان دیگری برساند ( لازم به ذکر است که برنامه طوری باشد که با عملگر توان نباشد یعنی عملگر توان اصلا" وجود نداشته و ما می خواهیم این عملگر را بوجود آوریم یا بهتر بگم بدون استفاده از عملگر توان و عملگر توان را با استفاده از کد در برنامه بوجودآوریم)
اگه امکان داره کد های برنامه مورد نظر را بنویسید
با تشکر
خیلی ساده بوود بازم سوال داشتی بپرس
این متن رو تو note pad با پسوند frm ذخیره کن و اجراکن
کد:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1515
ClientLeft = 60
ClientTop = 450
ClientWidth = 5460
LinkTopic = "Form1"
ScaleHeight = 1515
ScaleWidth = 5460
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Text3
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 1065
SubFormatType = 1
EndProperty
Height = 285
Left = 720
TabIndex = 3
Text = "0"
Top = 1080
Width = 4455
End
Begin VB.TextBox Text2
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 1065
SubFormatType = 1
EndProperty
Height = 285
Left = 3360
TabIndex = 2
Text = "0"
Top = 120
Width = 1935
End
Begin VB.TextBox Text1
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 1065
SubFormatType = 1
EndProperty
Height = 285
Left = 720
TabIndex = 1
Text = "0"
Top = 120
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "Answer"
Height = 495
Left = 1920
TabIndex = 0
Top = 480
Width = 1215
End
Begin VB.Label Label3
Caption = "Answer"
Height = 255
Left = 120
TabIndex = 6
Top = 1080
Width = 615
End
Begin VB.Label Label2
Caption = "Num2"
Height = 255
Left = 2760
TabIndex = 5
Top = 120
Width = 495
End
Begin VB.Label Label1
Caption = "Num1"
Height = 255
Left = 120
TabIndex = 4
Top = 120
Width = 495
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
On Error Resume Next
Dim Answer As String
Dim contor As Integer
contor = 1
Answer = Text1.Text
If Text1.Text = 0 Or Text2.Text < 0 Then
Answer = 0
Text3.Text = Answer
ElseIf Text2.Text = 0 Then
Answer = 1
Text3.Text = Answer
Else
Do Until contor = Text2.Text
Answer = Answer * Text1.Text
Text3.Text = Answer
contor = contor + 1
Loop
End If
contor = 1
Answer = 0
End Sub
Private Sub Text1_Click()
Text1.Text = ""
End Sub
Private Sub Text2_Click()
Text2.Text = ""
End Sub
یا اینکه 3 تا تکست باکس با یک کامند باتون بساز و این کد رو به فرم اضافه کن
()تکست باکس اول عدد اول رو میگیره تکست باکس دوم عدد دوم و تکست باک سوم جواب رو میده
کد:
Private Sub Command1_Click()
On Error Resume Next
Dim Answer As String
Dim contor As Integer
contor = 1
Answer = Text1.Text
If Text1.Text = 0 Or Text2.Text < 0 Then
Answer = 0
Text3.Text = Answer
ElseIf Text2.Text = 0 Then
Answer = 1
Text3.Text = Answer
Else
Do Until contor = Text2.Text
Answer = Answer * Text1.Text
Text3.Text = Answer
contor = contor + 1
Loop
End If
contor = 1
Answer = 0
End Sub
Private Sub Form_Load()
End Sub
Private Sub Text1_Click()
Text1.Text = ""
End Sub
Private Sub Text2_Click()
Text2.Text = ""
End Sub
:tongue: :tongue: :tongue: :tongue: :tongue: :tongue: :evil: :evil: :blink: :laughing: :) :biggrin: :rolleye: :cool: :tongue: :sad: :happy: :cool: :tongue: :blink: ;) :)