xinghesnak
发表于 2006-5-8 16:18:00
倒!把你的所有程序贴上来睽睽吧!
霹雳啪啦啦
发表于 2006-5-8 17:05:00
<P>我看不要搞这么复杂,刚学VB吗,就不要用动态数组,简单点:</P>
<P>dim pntArray(0 to 2, 0 to 20) as double</P>
<P>'假设最多20个点</P>
<P>for i=0 to 20</P>
<P>pntArray(i, 0)=第一个点的X坐标</P>
<P>pntArray(i,1)=第一个点的Y坐标</P>
<P>pntArray(i,2)=第一个点的Z坐标,如果二维制图就是0</P>
<P>next i</P>
<P>'如此就可以连续输入20个点坐标</P>
singlegu
发表于 2006-5-8 17:13:00
<P>Option Explicit</P>
<P>Sub Number()<BR> Static Matrix(1000) As Double<BR> Static i As Integer<BR> <BR> Matrix(i) = Val(TextBox1.Text)<BR> i = i + 1<BR> Matrix(i) = Val(TextBox2.Text)<BR> i = i + 1<BR> Matrix(i) = Val(TextBox3.Text)<BR> i = i + 1<BR> <BR>End Sub</P>
<P>Private Sub CommandButton1_Click()<BR> Call Number<BR> Unload UserForm1<BR> UserForm1.Show<BR> </P>
<P>End Sub<BR>这个是无法实现我想要的功能,可是我不知道怎么改,能帮我看看,告诉我该怎么改吗,谢谢!刚学VB,怎么简单的问题不要BS我啊,:)</P>
<P> </P>
singlegu
发表于 2006-5-8 18:03:00
我觉得7楼的程序没问题,会不会是我的引用有问题啊?请问你运行的时候用的是哪些引用啊?
xinghesnak
发表于 2006-5-9 08:27:00
<P>我的程序没有引用任何函数库,完全是VB自带的。。。。。</P>
<P>说一下你的程序,singlegu</P>
<P>不明白你为什么要再command的点击时间中加入</P>
<P>Unload UserForm1<BR> UserForm1.Show</P>
<P>这样很容易把你原来存下的数据数组清零,而且你的对数组和自变量i的声明要放在最顶端,不让你每次运行number程序就会重新定义一遍,同样保存不住数据</P>
<P>改成下面这样:</P>
<P>Dim Matrix(100) As Double<BR>Dim i As Integer</P>
<P>Sub Number()<BR> Matrix(i) = Val(Text1.Text)<BR> i = i + 1<BR> Matrix(i) = Val(Text2.Text)<BR> i = i + 1<BR> Matrix(i) = Val(Text3.Text)<BR> i = i + 1<BR> <BR>End Sub</P>
<P>Private Sub CommandButton1_Click()<BR> Call Number<BR>End Sub</P>
singlegu
发表于 2006-5-9 11:31:00
<P>在输入数据那个界面上,我想在输完数据后,点击"下一点"那个按扭,再调出原来那个输数据的界面</P>
<P><A name=11546><FONT color=#000066><B>xinghesnak</B></FONT></A>,你明白我的意思吗?</P>
xinghesnak
发表于 2006-5-9 11:39:00
奇怪,你在点击“下一点”按钮前后,界面有什么不同吗?要是还是想原来那样就把Dim Matrix(100) As Double,Dim i As Integer放在模块里,让程序先启动模块再加载你的窗体。。。。。。
singlegu
发表于 2006-5-9 16:49:00
<P>我想点击"下一点"后,原来输有数据的三个文本框都清空,能再输数据进去</P>
<P>要是不加</P>
<P> Unload UserForm1<BR> UserForm1.Show</P>
<P>这两句的话,点了下一点,文本框里还是原来输入的那几个数</P>
dchlmz
发表于 2006-5-9 17:05:00
<P>Dim Matrix(100) As Double<BR>Dim i As Integer</P>
<P>Sub Number()<BR> Matrix(i) = Val(Text1.Text)<BR> i = i + 1<BR> Matrix(i) = Val(Text2.Text)<BR> i = i + 1<BR> Matrix(i) = Val(Text3.Text)<BR> i = i + 1<BR> Text1.Text=""</P>
<P>Text2.Text=""</P>
<P>Text3.Text=""<BR>End Sub</P>
<P>Private Sub CommandButton1_Click()<BR> Call Number<BR>End Sub</P>
<P>这样可以不?</P>
singlegu
发表于 2006-5-9 17:42:00
<P>这是我的程序,目前问题是点击"输入完毕"按钮后,画不出线,实在不知道哪出了问题,请帮我看看吧,先谢过了啊!</P>
<P>Option Explicit<BR>Private Type POINTAPI<BR>x As Double<BR>y As Double<BR>z As Double<BR>End Type<BR>Dim p() As POINTAPI</P>
<P> </P>
<P> </P>
<P>Private Sub UserForm_Initialize()<BR>ReDim p(0) As POINTAPI<BR>End Sub</P>
<P><BR>Private Sub CommandButton1_Click()<BR> ' 确保文本框的值不为空<BR> Dim item As MSForms.Control<BR> For Each item In UserForm1.Controls<BR> If TypeOf item Is TextBox Then<BR> If Len(item.Text) = 0 Then<BR> MsgBox "请输入定位点!", vbCritical<BR> Exit Sub<BR> End If<BR> End If<BR> Next item<BR> <BR> '存点<BR> If p(0).x <> 0 Then ReDim Preserve p(UBound(p) + 1)</P>
<P> p(UBound(p)).x = Val(TextBox1.Text)<BR> p(UBound(p)).y = Val(TextBox2.Text)<BR> p(UBound(p)).z = Val(TextBox3.Text)</P>
<P> TextBox1.Text = ""<BR> TextBox2.Text = ""<BR> TextBox3.Text = ""<BR> </P>
<P><BR>End Sub</P>
<P> </P>
<P>Private Sub CommandButton2_Click()<BR> ' 确保文本框的值不为空<BR> Dim item As MSForms.Control<BR> For Each item In UserForm1.Controls<BR> If TypeOf item Is TextBox Then<BR> If Len(item.Text) = 0 Then<BR> MsgBox "请输入定位点!", vbCritical<BR> Exit Sub<BR> End If<BR> End If<BR> Next item<BR> <BR> <BR> ' 绘制直线<BR> Dim i As Integer<BR> Dim FormPnt(0 To 2) As Double<BR> Dim ToPnt(0 To 2) As Double<BR> For i = 2 To UBound(p)<BR> FormPnt(0) = p(i - 1).x<BR> FormPnt(1) = p(i - 1).y<BR> FormPnt(2) = p(i - 1).z<BR> ToPnt(0) = p(i).x<BR> ToPnt(1) = p(i).y<BR> ToPnt(2) = p(i).z<BR> <BR> ThisDrawing.ModelSpace.AddLine FormPnt, ToPnt<BR> <BR> Next<BR> End '结束程序<BR>End Sub<BR></P>