Başlangıç > Kodlar > Visual Basic 6 ile fonksiyon grafiği çizmek

Visual Basic 6 ile fonksiyon grafiği çizmek


Bu programa basit bir polinom fonksiyonun denklemini yazıyorsunuz o da size grafiğini çiziyo ama denklem ax^4+bx^3-cx^2+x+5 ... gibi yazılmalı

Program için malzeme listesi
1. Bir adet form
2. Bikaç label
3. İki adet textbox
4. İki adet buton
5. Bir adet pictureBox

Dim us, islem As Boolean
Dim sira, k As Integer
Dim dizi(20, 3) As String
Dim fonk As String
Dim krk As String * 1
Private Sub cmdCiz_Click()
Call Coz

List2.Clear
If Check1.Value = 1 Then
Picture1.Cls
End If
For i = -2970 To 2970
List2.AddItem hesapla(i) & "  " & CStr(i)
If Option1(0).Value = True Then
Picture1.PSet (i + 2970, 2970 - hesapla(i / 54) * 10), &H80000008
End If
If Option1(1).Value = True Then
Picture1.PSet (i + 2970, 2970 - hesapla(i)), &H80000008
End If
Next
End Sub

Sub Coz()
For i = 1 To 20
For j = 1 To 3
dizi(i, j) = ""
Next
Next
fonk = Trim(txtFonk)
If Mid(fonk, 1, 1) <> "+" And Mid(fonk, 1, 1) <> "-" Then
fonk = "+" & Trim(fonk)
End If
'MsgBox (Mid(fonk, 1, 1) + "   " + fonk)
sira = 1
k = 0
For sira = 1 To Len(fonk)
krk = Mid(fonk, sira, 1)
islem = False
If (krk = "+" Or krk = "-") And islem = False Then
k = k + 1
dizi(k, 1) = krk
us = False
'yyy'sira = sira + 1
islem = True
End If
If krk = "^" And islem = False Then
us = True
'sira = sira + 1
islem = True
End If
If (IsNumeric(krk) Or krk = ".") And us = False And islem = False Then
dizi(k, 2) = dizi(k, 2) + krk
'sira = sira + 1
islem = True
End If
If (IsNumeric(krk) Or krk = ".") And us = True And islem = False Then
dizi(k, 3) = dizi(k, 3) + krk
'sira = sira + 1
islem = True
End If
If krk = "x" And islem = False Then
'sira = sira + 1
islem = True
End If
Next
For i = 1 To k
If Trim(dizi(i, 2)) = "" Then
dizi(i, 2) = 1
End If
If Trim(dizi(i, 3)) = "" Then
dizi(i, 3) = 1
End If
List1.AddItem dizi(i, 1) + "  " + dizi(i, 2) + "  " + dizi(i, 3)
Next
End Sub

Function hesapla(x) As Double
For i = 1 To k '- 1
If i <> k Or (k < 2) Then
son = x ^ Val(dizi(i, 3)) * Val(dizi(i, 2))
If dizi(i, 1) = "+" Then
sonuc = sonuc + son
End If
If dizi(i, 1) = "-" Then
sonuc = sonuc - son
End If
End If
If (i = k) And (k > 1) Then
If dizi(i, 1) = "+" Then
sonuc = sonuc + dizi(i, 2)
End If
If dizi(i, 1) = "-" Then
sonuc = sonuc - dizi(i, 2)
End If
End If

Next
hesapla = sonuc
End Function

Private Sub Command1_Click()
Coz
Label1 = hesapla(Val(Text1.Text))
End Sub

Private Sub Command2_Click()
List1.Clear
End Sub

Orhan AYGÜN
Program ile ilgili önerileri ve geliştirmeleri bana bildirirseniz sevinirim
enkilman@hotmail.com


TD Software


  1. hd film izlesem
    23/05/2011, 23:25

    Tesekkurler gercekten harika bende bunu ariyordum en sonunda buldum tesekkur ederim…

    Beğen

  1. No trackbacks yet.

Yorum bırakın