Visual Basic Customization

Visual Basic Customization

Reply
Valued Contributor
pipu123
Posts: 61
Registered: ‎09-27-2010
Message 1 of 6 (176 Views)

User Form how to display distance in a Textbox userform

176 Views, 5 Replies
12-30-2011 12:34 AM

Type: sch  to run macro.  

 On the userform choose  "choose 2 points" 

how to display the Y distance and X distance in textboxes  ?

 

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 6 (171 Views)

Re: User Form how to display distance in a Textbox userform

12-30-2011 02:13 AM in reply to: pipu123

Something like:

Public Sub cmdPkt_S1_Click()
'With ThisDrawing.Utility
 
On Error Resume Next
    schuf.Hide
On Error GoTo Koniec
        ThisDrawing.SetVariable "OSMODE", 1  '' punkt
        ThisDrawing.Utility.InitializeUserInput 1
    pktaBaza01p = ThisDrawing.Utility.GetPoint(, "Wybierz 1 punkt")
If Err Then Exit Sub

On Error Resume Next
    schuf.Hide
        ThisDrawing.SetVariable "OSMODE", 1  '' punkt
        ThisDrawing.Utility.InitializeUserInput 1
    pktaBaza02p = ThisDrawing.Utility.GetCorner(pktaBaza01p, "Wybierz 2 punkt")
If Err Then Exit Sub
Dim wid As Double
wid = Abs(CDbl(pktaBaza01p(0) - pktaBaza02p(0)))
Dim hgt As Double
hgt = Abs(CDbl(pktaBaza01p(1) - pktaBaza02p(1)))
Dim b As String
b = CStr(wid)
Dim h As String
h = CStr(hgt)
Me.txtB.Text = b
Me.txtH.Text = h
Koniec:

schuf.Hide


Main01.Sch
' End With
End Sub

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
pipu123
Posts: 61
Registered: ‎09-27-2010
Message 3 of 6 (168 Views)

Re: User Form how to display distance in a Textbox userform

12-30-2011 03:20 AM in reply to: Hallex

Thank You for a proper solution

I am interested in other solution.  Details  are in the attachement. 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 6 (161 Views)

Re: User Form how to display distance in a Textbox userform

12-30-2011 05:16 AM in reply to: pipu123

Here is just for form module changes

made for the quick test only

Sorry I haven't have so much time

to write for you whole project

 

Option Explicit


Private Sub lblgr_Click()

End Sub

Private Sub schuf_Initialize()
'kod wykonywany w chwili uruchomienia okna
Dim z As String

'txtH.Text = "a"
If odnschPod <> 0 Then
 txtH.Text = ThisDrawing.odnschPodStr
End If

End Sub


Public Sub cmdPkt_S1_Click()
'With ThisDrawing.Utility
 
On Error Resume Next
    schuf.Hide
On Error GoTo Koniec
        ThisDrawing.SetVariable "OSMODE", 1  '' punkt
        ThisDrawing.Utility.InitializeUserInput 1
    pktaBaza01p = ThisDrawing.Utility.GetPoint(, "Wybierz 1 punkt")
If Err Then Exit Sub

On Error Resume Next
    schuf.Hide
        ThisDrawing.SetVariable "OSMODE", 1  '' punkt
        ThisDrawing.Utility.InitializeUserInput 1
    pktaBaza02p = ThisDrawing.Utility.GetPoint(pktaBaza01p, "Wybierz 2 punkt")
If Err Then Exit Sub

 

Dim wid As Double
wid = Abs(CDbl(pktaBaza02p(0) - pktaBaza01p(0)))
Dim txtWid As String
txtWid = CStr(wid)
Me.txtB.Text = txtWid

Dim hgt As Double
hgt = Abs(CDbl(pktaBaza02p(1) - pktaBaza01p(1)))
Dim txtHgt As String
txtHgt = CStr(hgt)
Me.txtH.Text = txtHgt

schuf.Show

' txtnsch = "text"
Koniec:

'commented for quick test :
'Main01.Sch
'Unload Me

 

' End With
End Sub

 

Private Sub txtnsch_Change()


If IsNumeric(txtnsch.Value) = True Then

Dim nsh As Integer
nsh = CInt(Me.txtnsch)
Dim ssh As Double
ssh = CDbl(Me.txtB) / nsh
Dim hsh As Double
hsh = CDbl(Me.txtH) / nsh
Me.txthsch.Text = CStr(hsh)
Me.txtssch.Text = CStr(ssh)
odNschodow = CInt(txtnsch.Value)
  
End If


End Sub

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
pipu123
Posts: 61
Registered: ‎09-27-2010
Message 5 of 6 (158 Views)

Re: User Form how to display distance in a Textbox userform

12-30-2011 05:52 AM in reply to: Hallex

Thank You for help

 

  

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 6 of 6 (151 Views)

Re: User Form how to display distance in a Textbox userform

12-30-2011 10:21 AM in reply to: pipu123

Just in addition

 

Do not add this line:

 

Unload Me

 

in the cmdOK button click

 

You can exit proejct from other button say cmdExit button

 

or from Main module at the end of Sub

 

Will be busy till 4-5 Jan.

 

Happy New Year

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.