我打開vb2005,給你編了一個,運行通過了,按回車重復(fù)執(zhí)行,按其他鍵退出,代碼如下:
創(chuàng)新互聯(lián)專注于順河企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站開發(fā),電子商務(wù)商城網(wǎng)站建設(shè)。順河網(wǎng)站建設(shè)公司,為順河等地區(qū)提供建站服務(wù)。全流程按需策劃,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Sub Main()
Randomize()
Do
Dim i As Integer = 10
Dim a(i - 1) As Integer
For j As Integer = 0 To i - 1
a(j) = CRND(300, 400)
Console.WriteLine(a(j).ToString)
Next
Dim mina As Integer = ProcMin(a)
Console.WriteLine(String.Format("最小值:{0}", mina))
Loop While Console.ReadKey.KeyChar = Chr(13)
End Sub
'產(chǎn)生隨機數(shù)
Private Function CRND(ByVal min As Int32, ByVal max As Int32) As Int32
If max min Then Return min
Return CInt(Int((max - min + 1) * Rnd() + min))
End Function
'獲取數(shù)組里的最小值
Private Function ProcMin(ByVal a() As Int32) As Int32
Dim tmp As Integer = Int32.MaxValue
For i As Integer = 0 To a.Length - 1
If tmp a(i) Then tmp = a(i)
Next
Return tmp
End Function
假如指定的lisp程序存入"e:\abcd.lsp",其中有函數(shù)gczd4-1帶有三個參數(shù)即(gczd4-1 X1 X2 X3)和命令cc,則VB.NET調(diào)用程序如下:
Dim AcadApp As Object
Dim AcadDoc As Object
AcadApp = GetObject(, "AutoCAD.Application")
AcadDoc = AcadApp.ActiveDocument
AcadDoc.SendCommand("(load " Chr(34) "e:\\abcd.lsp" Chr(34) ") ")
AcadDoc.SendCommand("(gczd4-1 " Chr(34) X1 Chr(34) Chr(34) X2 Chr(34) Chr(34) X3 Chr(34) ") ")
AcadDoc.SendCommand("(c:cc) ")
AcadDoc = Nothing
AcadApp = Nothing
新建窗口,添加picture控件
利用line()方法畫線
line(開始x坐標(biāo),開始y坐標(biāo))-(結(jié)束x坐標(biāo),結(jié)束y坐標(biāo)),線的顏色,畫線的方式(默認(rèn)為線,B為矩形無填充,BF為填充的矩形)
For i = 1 To 16
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(255, 0, 0)
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(255, 0, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(0, 255, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(0, 255, 0)
Next i
如果要在窗口上畫也可以調(diào)用窗口的line方法即form.line()