怎麼用VB畫函式影象,如何用vb畫出簡易函式影象

時間 2022-02-04 13:40:02

1樓:匿名使用者

那個你總得有個函式來畫呀。你出一個函式我上**下面上一個正弦函式的**,其餘的你也可以類推private sub command1_click()dim jd as double

dim x as double

dim y as double

me.picture1.scale (-10, 10)-(360, -10)

me.picture1.line (-10, 0)-(100, 0)for i = 1 to 360

x = i

jd = i * 3.14 / 180

y = 5 * sin(jd)

me.picture1.pset (x, y)next i

end sub

private sub form_load()me.width = 16000

me.height = 12000

me.picture1.height = 8200me.picture1.width = 11145end sub

2樓:vb程式設計解放雙手

就是畫點,由點連成線!

如何用vb畫出簡易函式影象

3樓:匿名使用者

用vb畫出簡易函式影象的操作步驟為:

(1)新建一個工程,新建一個form1,在上面新增一個picture控制元件和一個command控制元件;

(2)選中此控制元件,右擊"複製",在窗體空白處右擊"貼上",在彈出的對話方塊中選擇"是",建立了一個command控制元件陣列,複製,使窗體上總共出現7個command控制元件;

(3)複製**:

const pi = 3.1415926535 '定義圓周率

dim a, wor

dim i as integer

static function loge(x)

loge = log(x) / log(exp(1))

end function

'定義用於在picture1上的一個位置列印字元函式

private function printword(x, y, word as string)

with picture1

.currentx = x

.currenty = y

.forecolor = rgb(0, 0, 255)

end with

picture1.print word

end function

private function drawdot(px, py, color)

picture1.pset (px, py), color

end function

sub xy() '建立直角座標系

picture1.drawwidth = 1 '設定線條寬度

picture1.cls

'設定使用者座標系,座標原點在picture1中心

picture1.scale (-10, 10)-(10, -10)

picture1.line (-10, 0)-(10, 0), rgb(0, 0, 255)

picture1.line -(9.5, 0.5), rgb(0, 0, 255)

picture1.line (10, 0)-(9.5, -0.5), rgb(0, 0, 255)

picture1.forecolor = rgb(0, 0, 255)

picture1.print "x"

'畫 x 軸

picture1.line (0, -10)-(0, 10), rgb(0, 0, 255)

picture1.line -(0.5, 9.5), rgb(0, 0, 255)

picture1.line (0, 10)-(-0.5, 9.5), rgb(0, 0, 255)

picture1.print "y"

'畫 y 軸

for lin = -9 to 9

picture1.line (lin, 0)-(lin, 0.25)

wor = printword(lin - 0.5, -0.5, str(lin))

picture1.line (0, lin)-(-0.25, lin)

if lin <> 0 then

wor = printword(-0.9, lin, str(lin))

end if

next lin

picture1.drawwidth = 2

end sub

private sub command1_click(index as integer)

select case index

case 0

for a = -3 to 3 step pi / 6000

dot = drawdot(a, a ^ 2, rgb(0, 0, 0))

next a

wor = printword(4, 9, "二次曲線 y=x^2")

case 1

for a = -9 to 9 step pi / 6000

dot = drawdot(a, a, rgb(0, 0, 0))

next a

wor = printword(8, 5, "一次曲線 y=x")

case 2

for a = -9 to 3 step pi / 6000

dot = drawdot(a, exp(a), rgb(0, 0, 0))

next a

wor = printword(4, 9, "指數曲線 y=e^x")

case 3

for a = 0.0001 to 9 step pi / 6000

dot = drawdot(a, loge(a), rgb(0, 0, 0))

next a

wor = printword(8, 3, "對數曲線 y=ln x")

case 4

for a = -10 to 10 step pi / 6000

dot = drawdot(a, sin(a), rgb(0, 0, 0))

next a

wor = printword(-5, 2, "正弦曲線 y=sin x")

case 5

for a = -10 to 10 step pi / 6000

dot = drawdot(a, cos(a), rgb(0, 0, 0))

next a

wor = printword(-9, 2, "餘弦曲線 y=cos x")

case 6

xyend select

end sub

private sub form_load()

me.caption = "數學函式作圖?quot;"

me.show

me.autoredraw = true

picture1.autoredraw = true

command1(0).caption = "二次曲線"

command1(1).caption = "一次曲線"

command1(2).caption = "指數曲線"

command1(3).caption = "對數曲線"

command1(4).caption = "正弦曲線"

command1(5).caption = "餘弦曲線"

command1(6).caption = "清空"

xyend sub

private sub form_resize()

picture1.width = me.width * 0.94

picture1.height = me.height - (command1(0).height * 4 + 100)

command1(0).top = me.height - (command1(0).height * 2.5 + 100)

command1(0).left = me.width * 0.01

for i = 1 to 6

command1(i).top = me.height - (command1(0).height * 2.5 + 100)

command1(i).left = command1(i - 1).left + 1000

next

xyend sub

4樓:day飄雪的風景

第一步,新建一個工程,新建一個form1,在上面新增一個picture控制元件和一個command控制元件,然後選中此控制元件,右擊"複製",在窗體空白處右擊"貼上",在彈出的對話方塊中選擇"是",建立了一個command控制元件陣列,複製,使窗體上總共出現7個command控制元件,然後複製**:

const pi = 3.1415926535 '定義圓周率

dim a, wor

dim i as integer

static function loge(x)

loge = log(x) / log(exp(1))

end function

'定義用於在picture1上的一個位置列印字元函式

private function printword(x, y, word as string)

with picture1

.currentx = x

.currenty = y

.forecolor = rgb(0, 0, 255)

end with

picture1.print word

end function

private function drawdot(px, py, color)

picture1.pset (px, py), color

end function

sub xy() '建立直角座標系

picture1.drawwidth = 1 '設定線條寬度

picture1.cls

'設定使用者座標系,座標原點在picture1中心

picture1.scale (-10, 10)-(10, -10)

picture1.line (-10, 0)-(10, 0), rgb(0, 0, 255)

picture1.line -(9.5, 0.5), rgb(0, 0, 255)

picture1.line (10, 0)-(9.5, -0.5), rgb(0, 0, 255)

picture1.forecolor = rgb(0, 0, 255)

picture1.print "x"

'畫 x 軸

picture1.line (0, -10)-(0, 10), rgb(0, 0, 255)

picture1.line -(0.5, 9.5), rgb(0, 0, 255)

picture1.line (0, 10)-(-0.5, 9.5), rgb(0, 0, 255)

picture1.print "y"

'畫 y 軸

for lin = -9 to 9

picture1.line (lin, 0)-(lin, 0.25)

wor = printword(lin - 0.5, -0.5, str(lin))

picture1.line (0, lin)-(-0.25, lin)

if lin <> 0 then

wor = printword(-0.9, lin, str(lin))

end if

next lin

picture1.drawwidth = 2

end sub

private sub command1_click(index as integer)

select case index

case 0

for a = -3 to 3 step pi / 6000

dot = drawdot(a, a ^ 2, rgb(0, 0, 0))

next a

wor = printword(4, 9, "二次曲線 y=x^2")

case 1

for a = -9 to 9 step pi / 6000

dot = drawdot(a, a, rgb(0, 0, 0))

next a

wor = printword(8, 5, "一次曲線 y=x")

case 2

for a = -9 to 3 step pi / 6000

dot = drawdot(a, exp(a), rgb(0, 0, 0))

next a

wor = printword(4, 9, "指數曲線 y=e^x")

case 3

for a = 0.0001 to 9 step pi / 6000

dot = drawdot(a, loge(a), rgb(0, 0, 0))

next a

wor = printword(8, 3, "對數曲線 y=ln x")

case 4

for a = -10 to 10 step pi / 6000

dot = drawdot(a, sin(a), rgb(0, 0, 0))

next a

wor = printword(-5, 2, "正弦曲線 y=sin x")

case 5

for a = -10 to 10 step pi / 6000

dot = drawdot(a, cos(a), rgb(0, 0, 0))

next a

wor = printword(-9, 2, "餘弦曲線 y=cos x")

case 6

xyend select

end sub

private sub form_load()

me.caption = "數學函式作圖?quot;"

me.show

me.autoredraw = true

picture1.autoredraw = true

command1(0).caption = "二次曲線"

command1(1).caption = "一次曲線"

command1(2).caption = "指數曲線"

command1(3).caption = "對數曲線"

command1(4).caption = "正弦曲線"

command1(5).caption = "餘弦曲線"

command1(6).caption = "清空"

xyend sub

private sub form_resize()

picture1.width = me.width * 0.94

picture1.height = me.height - (command1(0).height * 4 + 100)

command1(0).top = me.height - (command1(0).height * 2.5 + 100)

command1(0).left = me.width * 0.01

for i = 1 to 6

command1(i).top = me.height - (command1(0).height * 2.5 + 100)

command1(i).left = command1(i - 1).left + 1000

next

xyend sub

vb鎖鍵盤,如何用VB鎖鍵盤

用c語言寫一個dll,注入到系統程序中,然後就可以hook了不過這樣很麻煩,有個簡單的方法。你這樣做不過是想鎖住計算機,讓小鍵盤可以輸密碼對吧這裡有一個程式可以實現。vb 鎖鍵盤 我發到你的郵箱裡了,有加註釋。到街上,應該不難找到賣鎖的,選擇一個合適你鍵盤的不就得了,這上面問什麼!誰還是開鎖鋪的不成...

int函式怎麼用,vb裡int函式怎麼用 和fix函式區別是什麼

int 函式表示的是函式的返回值型別為int型的資料。每個函式執行完畢後可以產生一個結果,我是說可以,你當然也可以不用。舉個例子。int max int a,int b return就是表示函式的返回值型別為一個叫做int型的資料,這裡是a和b裡面的最大數字,函式的返回值必須和產生資料的資料型別一致...

VB怎麼編寫四則運算,如何用VB進行加減乘除運算

dim num1,num2 as single 下面是用來處理數字的 dim strnum1,strnum2 as string dim firstnum as boolean 判斷是否是數字開頭 dim pointflag as boolean 判斷是否已有小數點 這是處理小數點的 dim run...