Here is example borrowed from web,
change to your suit :
Function getClass(ByVal myClassName As String)
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim prStrOpts As New PromptStringOptions("Class Name <" + myClassName + ">")
Dim prResult As PromptResult
prStrOpts.AllowSpaces = True
prStrOpts.AppendKeywordsToMessage = True
prResult = ed.GetString(prStrOpts)
If prResult.Status = PromptStatus.OK Then
If prResult.StringResult.Equals("") Then
Return myClassName
Else
Return prResult.StringResult
End If
Else
Return myClassName
End If
End Function
'Puts the text values into ACAD as MTEXT
Sub putClassMText(ByVal loc As Point3d, ByVal myClassName As String, _
ByVal myInstructor As String, ByVal myHrs As Double)
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim myT As Transaction = HostApplicationServices.WorkingDatabase().TransactionManager.StartTransaction()
Try
'Open the block table in order to access the ModelSpace
'bt receives the BlockTable Object using the transaction manager
Dim bt As BlockTable = _
CType(myT.GetObject(db.BlockTableId, OpenMode.ForRead, False), BlockTable)
'Open the modelspace for write
'btr receives the ModelSpace Object using the transaction manager
Dim btr As BlockTableRecord = _
CType(myT.GetObject(bt(BlockTableRecord.ModelSpace), _
OpenMode.ForWrite, False), BlockTableRecord)
Dim mtext As New MText 'This is the Mtext that is added to ModelSpace
'mtext.Contents = "Class: " + myClassName + vbLf + _
'"Instructor: " + myInstructor + vbLf + _
'[String].Format("Hours=: {0:#.##}", myHrs)
mtext.Contents = goDialog(myClassName, myInstructor, myHrs)
mtext.Location = loc 'Point3D
'Add the MText to the btr Object
btr.AppendEntity(mtext)
'Inform the transaction manager of the addition
myT.AddNewlyCreatedDBObject(mtext, True)
'Commit the transaction
myT.Commit()
Catch ex As Exception
'Error catching is not really necessary since we will dispose
'of the transaction in the finally block.
MsgBox(Err.Description)
Finally
'We are finished using this transaction
myT.Dispose()
End Try
End Sub
'Displays a dialog to retrieve the values
Function goDialog(ByRef myClassName As String, ByVal myInstructor As String, ByRef myHrs As Double) As String
'Dim dlgLoopy As New dlgLoopy
Dim sb As New StringBuilder
'dlgLoopy.TextBox1.Text = myClassName
'dlgLoopy.TextBox2.Text = myInstructor
'dlgLoopy.ComboBox1.Text = String.Format("{0:#.##}", myHrs)
sb.AppendLine(myClassName)
sb.AppendLine(myInstructor)
sb.AppendLine(String.Format("{0:#.##}", myHrs))
'Show dialog as modal (xxx.Show() is non-modal)
'Application.ShowModalDialog(dlgLoopy)
'If dlgLoopy.DialogResult = Windows.Forms.DialogResult.OK Then
' myClassName = dlgLoopy.TextBox1.Text
' myInstructor = dlgLoopy.TextBox2.Text
' myHrs = CDbl(dlgLoopy.ComboBox1.Text)
'End If
'dlgLoopy.Dispose()
Return sb.ToString
End Function
<CommandMethod("gof")> _
Public Sub LoopPointsExample()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
'Establish default values
Dim strClassName As New String("Going Loopy")
Dim strInstructor As New String("Doug Goforth")
Dim dblHours As New Double
dblHours = 1.5
Dim keepLooping As Boolean = True
'Start the command loop
While keepLooping
Try
Dim pto As PromptPointOptions = New PromptPointOptions(vbLf + "Pick point or: ")
'Establish the valid keywords for the prompt
pto.Keywords.Add("Dialog")
pto.Keywords.Add("Class")
pto.Keywords.Add("Instructor")
pto.Keywords.Add("Hours")
pto.Keywords.Add("Quit")
pto.Keywords.Add("?")
pto.AllowNone = True 'Allow user to just press ENTER
pto.AppendKeywordsToMessage = True
Dim res As PromptPointResult
'Display the prompt (use GetPoint when expecting a point or keyword)
res = ed.GetPoint(pto)
'Respond to the possible prompt results...
Select Case res.Status
Case PromptStatus.OK
'Point was provided
putClassMText(res.Value, strClassName, strInstructor, dblHours)
Case PromptStatus.Keyword
'User responded with one of the valid keywords
'established in the PromptPointOptions
Select Case res.StringResult
Case "Dialog"
goDialog(strClassName, strInstructor, dblHours)
keepLooping = True
Case "Hours"
dblHours = dblHours 'getHours(dblHours)
keepLooping = True
Case "Instructor"
strInstructor = strInstructor 'getInstructor(strInstructor)
keepLooping = True
Case "Class"
strClassName = getClass(strClassName)
keepLooping = True
Case "?"
ed.WriteMessage(vbLf + " Class: " + strClassName)
ed.WriteMessage(vbLf + " Instructor: " + strInstructor)
ed.WriteMessage(vbLf + " " + [String].Format("Hours: {0:#.##}", dblHours))
keepLooping = True
Case "Quit"
keepLooping = False
Case Else
keepLooping = False
End Select
Case PromptStatus.Cancel
'User pressed escape
keepLooping = False
Case PromptStatus.None
'User pressed ENTER
keepLooping = False
Case Else 'Other erroneous input
keepLooping = True
End Select
Catch ex As Exception 'Catch the error to continue processing
'Should not happen if all the possible
'return values from the prompt are handled
MsgBox(Err.Description)
End Try
End While
End Sub
_____________________________________
C6309D9E0751D165D0934D0621DFF27919