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>&nbsp;&nbsp; Static Matrix(1000) As Double<BR>&nbsp;&nbsp; Static i As Integer<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; Matrix(i) = Val(TextBox1.Text)<BR>&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; Matrix(i) = Val(TextBox2.Text)<BR>&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; Matrix(i) = Val(TextBox3.Text)<BR>&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; <BR>End Sub</P>
<P>Private Sub CommandButton1_Click()<BR>&nbsp;&nbsp; Call Number<BR>&nbsp;&nbsp; Unload UserForm1<BR>&nbsp;&nbsp; UserForm1.Show<BR>&nbsp;&nbsp; </P>
<P>End Sub<BR>这个是无法实现我想要的功能,可是我不知道怎么改,能帮我看看,告诉我该怎么改吗,谢谢!刚学VB,怎么简单的问题不要BS我啊,:)</P>
<P>&nbsp;</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>&nbsp;&nbsp; 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>&nbsp;&nbsp; Matrix(i) = Val(Text1.Text)<BR>&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; Matrix(i) = Val(Text2.Text)<BR>&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; Matrix(i) = Val(Text3.Text)<BR>&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; <BR>End Sub</P>
<P>Private Sub CommandButton1_Click()<BR>&nbsp;&nbsp; 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>&nbsp;&nbsp; Unload UserForm1<BR>&nbsp;&nbsp; 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>&nbsp;&nbsp; Matrix(i) = Val(Text1.Text)<BR>&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; Matrix(i) = Val(Text2.Text)<BR>&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; Matrix(i) = Val(Text3.Text)<BR>&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; Text1.Text=""</P>
<P>Text2.Text=""</P>
<P>Text3.Text=""<BR>End Sub</P>
<P>Private Sub CommandButton1_Click()<BR>&nbsp;&nbsp; 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>&nbsp;</P>
<P>&nbsp;</P>
<P>Private Sub UserForm_Initialize()<BR>ReDim p(0) As POINTAPI<BR>End Sub</P>
<P><BR>Private Sub CommandButton1_Click()<BR>&nbsp;&nbsp;&nbsp; ' 确保文本框的值不为空<BR>&nbsp;&nbsp;&nbsp; Dim item As MSForms.Control<BR>&nbsp;&nbsp;&nbsp; For Each item In UserForm1.Controls<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If TypeOf item Is TextBox Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Len(item.Text) = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "请输入定位点!", vbCritical<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next item<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; '存点<BR>&nbsp;&nbsp; If p(0).x &lt;&gt; 0 Then ReDim Preserve p(UBound(p) + 1)</P>
<P>&nbsp;&nbsp; p(UBound(p)).x = Val(TextBox1.Text)<BR>&nbsp;&nbsp; p(UBound(p)).y = Val(TextBox2.Text)<BR>&nbsp;&nbsp; p(UBound(p)).z = Val(TextBox3.Text)</P>
<P>&nbsp;&nbsp; TextBox1.Text = ""<BR>&nbsp;&nbsp; TextBox2.Text = ""<BR>&nbsp;&nbsp; TextBox3.Text = ""<BR>&nbsp; </P>
<P><BR>End Sub</P>
<P>&nbsp;</P>
<P>Private Sub CommandButton2_Click()<BR>&nbsp;&nbsp;&nbsp; ' 确保文本框的值不为空<BR>&nbsp;&nbsp;&nbsp; Dim item As MSForms.Control<BR>&nbsp;&nbsp;&nbsp; For Each item In UserForm1.Controls<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If TypeOf item Is TextBox Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Len(item.Text) = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "请输入定位点!", vbCritical<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next item<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 绘制直线<BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp; Dim FormPnt(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim ToPnt(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; For i = 2 To UBound(p)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(0) = p(i - 1).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(1) = p(i - 1).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(2) = p(i - 1).z<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(0) = p(i).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(1) = p(i).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(2) = p(i).z<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.AddLine FormPnt, ToPnt<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp; '结束程序<BR>End Sub<BR></P>
页: 1 [2] 3
查看完整版本: 小女子跪求各位大虾