数学建模社区-数学中国

标题: 帮帮忙,谢谢大侠,VB [打印本页]

作者: llm3-1415926    时间: 2005-1-17 22:01
标题: 帮帮忙,谢谢大侠,VB
<>rivate Sub cmdPlot_Click()
& o4 @8 t; Z- V4 U6 ^9 C! wXY
' G# p1 x& c0 C* q0 e/ v# gOn Error Resume Next; V6 ^5 Z2 I5 ]4 ]0 N$ D' \  S
Dim x As Double, Y As Double
- k3 e8 T  F$ M: w( ? Randomize- }7 s9 X# p" ], Y" l0 Q8 j9 a/ \7 H& u
  
7 J2 A6 N3 h9 [. x: Q- H        SC.Reset4 t8 O: U, @# |+ q5 L
        SC.AddCode "Function RunThis(X)" &amp; vbCrLf &amp; "RunThis=" &amp; txtEquation &amp; vbCrLf &amp; "End Function"5 E# `6 ~& H9 i& a9 V( ?4 Q7 N
       For x = -15 To 15 Step 0.001
; [3 Y- Z  E% b" P/ X  w  n         Y = SC.Run("runthis", x)
2 V/ h3 e5 \0 {         DoEvents; J$ L% \, r2 k$ L2 z" n
          Picture1.PSet (x, Y), RGB(250, 0, 0)4 x& o5 n+ P* R; M
          Next x
" L5 C- `1 m" z6 rEnd Sub</P>
9 U9 A) e) s$ J; Y<>为仕么Y=LOG(X),SQR(X)也有图象(X轴负半轴),请帮忙</P>
作者: USER001    时间: 2005-1-18 10:44
把完整代码发上来
作者: llm3-1415926    时间: 2005-3-1 23:50
<><b>帮帮忙,跪下谢谢斑竹,VB</b></P><>rivate Function PrintWord(x, Y, Word As String)
/ G8 b. n; R' k) g# B% MWith Picture1( B! ~0 n& u% Y/ U4 @
.CurrentX = x5 ?, w- B- T* T  b
.CurrentY = Y. T; b& X/ I/ [# G- p6 k* \3 Z
.ForeColor = RGB(0, 0, 255)6 J; W4 j7 \5 f, {
End With
9 w+ B$ N5 D5 C0 JPicture1.Print Word+ b. h3 x% O8 x& g- k1 b
End Function
& u3 Z1 ], P( {6 B'定义画点函数
  z$ A; q8 M. {( C& kPrivate Function DrawDot(Px, Py, Color)& ^: J6 t& r7 w% k! F
Picture1.PSet (Px, Py), Color
2 @- V3 F2 l9 u- h/ WEnd Function
/ ~! s# f" c+ v$ hSub XY() '建立直角坐标系
' }) w- [$ x3 m9 _) H$ \Picture1.DrawWidth = 1 '设置线条宽度
9 W1 O& O# s" i6 M6 _( \+ l2 APicture1.Cls
$ t5 K% l) y6 |9 R'设定用户坐标系,坐标原点在Picture1中心
! L( u1 I5 I& v/ l* {; B& vPicture1.Scale (-10, 10)-(10, -10)
( d  f! U* a3 XPicture1.Line (-10, 0)-(10, 0), RGB(0, 0, 255)
0 v' ~( D; `6 [. f" o4 WPicture1.Line -(9.5, 0.5), RGB(0, 0, 255)
/ m7 M* Y; X. G+ CPicture1.Line (10, 0)-(9.5, -0.5), RGB(0, 0, 255)
- z$ Z' q* `  i! ePicture1.ForeColor = RGB(0, 0, 255)! o" K9 O, c6 `9 N
Picture1.Print "X"
0 Y6 w3 z& M. A7 c4 \% j( ]'画 X 轴% p, _6 x$ {: ]0 ~
Picture1.Line (0, -10)-(0, 10), RGB(0, 0, 255)
4 p2 j  o( }* _! Q) hPicture1.Line -(0.5, 9.5), RGB(0, 0, 255)
- s6 Z$ c$ c" vPicture1.Line (0, 10)-(-0.5, 9.5), RGB(0, 0, 255)0 f) j. M) U" h, R3 L" P
Picture1.Print "Y"  u$ @% s+ }! R+ r$ h* d9 z9 k' n
'画 Y 轴& m4 L" A. ]* d5 {# d& V: a
For lin = -9 To 9
) @, o' H* ^- v; G4 UPicture1.Line (lin, 0)-(lin, 0.25)
/ a3 Z6 T' F. q& O1 _7 u; V# hwor = PrintWord(lin - 0.5, -0.5, Str(lin))  T* z/ D3 c+ b1 X/ y! L6 d  o
Picture1.Line (0, lin)-(-0.25, lin)0 }  f1 n, l% y% ?4 O# E
If lin &lt;&gt; 0 Then4 y7 W1 X# E: q  `  l9 ~8 M
wor = PrintWord(-0.9, lin, Str(lin))
4 n7 f2 S9 ?. w) i( oEnd If
* \0 |/ g$ @7 @8 z/ @Next lin
% X( V, |4 P$ o! vPicture1.DrawWidth = 1! [* T4 n3 g$ H) S1 O! Y/ P" J
End Sub
, u: J' V& V7 A4 EPrivate Sub cmdPlot_Click()) ?& c: ?: V# M% @1 u) B
XY
/ ]( w: ]6 \( n' vOn Error Resume Next
2 z* v- |6 |% G6 M2 g4 X0 i Dim x As Double, Y As Double
1 g8 ]# \) t( C3 A, @* x Randomize
; q0 I, \2 a; q9 R# w/ q6 ~" b    D. d$ g" d$ q# E, v
        SC.Reset2 \2 }: y; U! H8 K+ F: F/ h- u/ @
        SC.AddCode "Function RunThis(X)" &amp; vbCrLf &amp; "RunThis=" &amp; txtEquation &amp; vbCrLf &amp; "End Function"  W+ ?+ V6 U8 c3 j
       For x = -15 To 15 Step 0.001
2 _0 m8 c# Y; r8 w4 P         Y = SC.Run("runthis", x)
: y- A. x" N: E         DoEvents
9 N1 v) W- R; i* s7 Z          Picture1.PSet (x, Y), RGB(250, 0, 0)
1 B& B4 }6 n5 r) V# Y          Next x
+ ?% G! `8 i. T2 M- e* E# QEnd Sub</P><>rivate Sub Command2_Click()
- i/ u6 q; K8 f( }XY4 R1 o: o8 l0 T( U7 J* R% q
End Sub</P><>rivate Sub Command3_Click()
1 ]+ n5 _- o# K" v# X" m* YEnd' N2 e# ]" I! W
End Sub</P><>
; f. m2 T5 c' B+ W  ]Private Sub Form_Load()% O1 ^3 K8 L: |5 u6 Q
Me.Caption = "美丽曲线——山东省商河一中路来民", s! p2 ?) ~3 p3 U
Me.Show3 j5 R0 y1 A: A! k, R: i8 c
Me.AutoRedraw = True
6 U2 E2 z* k, e8 R* yXY  y0 H3 i# L3 P
End Sub4 b4 f9 ~6 m, W. _& i& l
控件</P><>为仕么Y=LOG(X),SQR(X)也有图象(X轴负半轴), SC为MS.SCRIPT.control请帮忙,谢谢斑竹,跪谢!!!</P>
作者: 秋天的风儿    时间: 2011-9-23 15:19
呵呵,看大家评论如何
2 B8 q6 f" ~$ M5 o" I4 B9 d/ O
, R, p5 |; m9 O4 Q. A/ g
: H$ p& Z" P& p% v
8 d" m+ a+ k- U5 |0 k
. y& Z: X( E& @7 [/ l# A* W! D
4 x( \! [8 {: v' _* J( @4 [4 B: Y) Z4 ~2 G

9 n: |' n; h9 f; J% q5 q
4 b# e" l8 r/ g  s6 ^# O8 ~1 j" V2 e
, a/ f# g. x6 |
9 Y7 D3 \6 L6 h
3 t. G- g2 Z" I- C8 Z- x3 u
- P4 R8 h7 F/ z) G大家好,能交朋友嘛?ok0633.com
作者: ealx0yJu    时间: 2012-10-13 03:38
我看不错噢 谢谢楼主!




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5