高手帮忙啊
http://hi.baidu.com/princessakura/album/item/c56dc709536eac2a95ca6bd6.html(图一)
实在是不知道怎么发图,就把界面弄到这个地址了,直接打开就可以看。
Private Sub Command23_Click() ‘Command23为插入标点点那个按键
frmadd.Show 1, Form_main
End Sub
点击完之后会出现一个框,往里面输入标定点的值。图见:http://hi.baidu.com/princessakura/album/item/251dfd3742b63b82d0a2d3a2.html(图二)
点击那个确定之后,要判断输入的那个值是在(图一)那十个点的哪两个点之间,然后插入这个点。这个点后的点依次往后移一位 现在就是这个地方不会
高手救命!
[解决办法]
你这个是保留值最高的十个点吗?
建议:
1,把那十个OptionButton取名为optPos的控件数组,Index值依次从1到10,每个控件的Tag属性中存放相应的标定点的值。
2,因为你这个数据的元素个数比较少,所以排序用冒泡排序,查找用顺序查找就够了
[解决办法]
新建一个窗口,放一个文本框,然后放一个option选项按钮,然后放一个按钮,均不需要改名字,然后把以下代放放在窗口代码里,然后运行。本程序支持插入任意值,并会自动排序插入。
Option ExplicitPrivate Sub initOpt() Dim oOpt As OptionButton Dim i As Long For i = 1 To 9 Load Option1(i) Set oOpt = Option1(i) oOpt.Move Option1(i - 1).Left, Option1(i - 1).Top + Option1(i - 1).Height + 10 * Screen.TwipsPerPixelX oOpt.Tag = (i + 1) / 10 oOpt.Caption = "第" & i + 1 & "点 (" & Format(oOpt.Tag, "0.00#") & ")" oOpt.Visible = True Next iEnd SubPublic Function getRadoGroutValue(ByRef 单选按钮组名称 As Object) As String '取得一组单选按钮中选中的值 Dim i As Integer For i = 0 To 单选按钮组名称.Count - 1 If 单选按钮组名称(i).Value = True Then getRadoGroutValue = CStr(i) Exit For End If Next iEnd FunctionPrivate Sub Command1_Click() Dim dblValue As Double Dim lIndex As Long Dim i As Long Dim oOpt As OptionButton Dim dblArr() As Double ReDim dblArr(Option1.UBound + 1) dblValue = CDbl(Text1.Text) For i = 0 To Option1.UBound dblArr(i) = Option1(i).Tag Next i '排序 dblArr(Option1.UBound + 1) = dblValue Quicksort dblArr, 0, UBound(dblArr) lIndex = FindIndexInArr(dblValue, dblArr) Load Option1(Option1.UBound + 1) Set oOpt = Option1(Option1.UBound) i = Option1.UBound - 1 oOpt.Move Option1(i).Left, Option1(i).Top + Option1(i).Height + 10 * Screen.TwipsPerPixelX oOpt.Visible = True '插入值 For i = UBound(dblArr) To lIndex Step -1 Set oOpt = Option1(i) oOpt.Tag = dblArr(i) oOpt.Caption = "第" & i + 1 & "点 (" & Format(oOpt.Tag, "0.00#") & ")" Next iEnd SubPrivate Function FindIndexInArr(ByVal dblVal As Double, ByRef dblArr() As Double) As Long Dim lIndex As Long FindIndexInArr = -1 For lIndex = 0 To UBound(dblArr) If dblVal = dblArr(lIndex) Then FindIndexInArr = lIndex Exit For End If NextEnd Function'快速排序' Sort the items in array values() with bounds min and max.'CSEH: ErrRaiseSub Quicksort(values As Variant, ByVal Min As Long, ByVal Max As Long) Dim med_value As String Dim hi As Long Dim lo As Long Dim i As Long ' If the list has only 1 item, it's sorted. If Min >= Max Then Exit Sub ' Pick a dividing item randomly. i = Min + Int(Rnd(Max - Min + 1)) med_value = values(i) ' Swap the dividing item to the front of the list. values(i) = values(Min) ' Separate the list into sublists. lo = Min hi = Max Do ' Look down from hi for a value < med_value. Do While values(hi) >= med_value hi = hi - 1 If hi <= lo Then Exit Do Loop If hi <= lo Then ' The list is separated. values(lo) = med_value Exit Do End If ' Swap the lo and hi values. values(lo) = values(hi) ' Look up from lo for a value >= med_value. lo = lo + 1 Do While values(lo) < med_value lo = lo + 1 If lo >= hi Then Exit Do Loop If lo >= hi Then ' The list is separated. lo = hi values(hi) = med_value Exit Do End If ' Swap the lo and hi values. values(hi) = values(lo) Loop ' Recursively sort the sublists. Quicksort values, Min, lo - 1 Quicksort values, lo + 1, MaxEnd SubPrivate Sub Form_Load() Text1.Text = "0.17" Option1(0).Tag = 0.1 Option1(0).Width = 100 * Screen.TwipsPerPixelX Option1(0).Caption = "第1点(0.10)" initOptEnd Sub