Visual Basic Customization

Visual Basic Customization

Reply
Valued Contributor
61 Posts
0 Kudos
Registered: ‎09-27-2010
Post 1 of 6

User Form how to display distance in a Textbox userform

177 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*
1,569 Posts
171 Kudos
Registered: ‎10-08-2008
Post 2 of 6

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
61 Posts
0 Kudos
Registered: ‎09-27-2010
Post 3 of 6

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*
1,569 Posts
171 Kudos
Registered: ‎10-08-2008
Post 4 of 6

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
61 Posts
0 Kudos
Registered: ‎09-27-2010
Post 5 of 6

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*
1,569 Posts
171 Kudos
Registered: ‎10-08-2008
Post 6 of 6

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