Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with VB coding ASAP plzzzzzzzzzz

Status
Not open for further replies.

harmo81

Computer
Feb 4, 2006
1
Could anyone plz REWORD the following code (not comments) but still functions in exactly the same way as expressed below. The vb program is supposed to connect with AVS/Express. The program should allow the user to create a profile in 2D and then to generate the solid (bottle shape). Many Thanks!

'Declares variables
Dim iAngle As Integer
Dim fX2, fY2, fX1, fY1, fZ1, fZ2 As Double
Dim iLoop As Integer
Dim fRadians As Double
Dim fRadius As Integer
Dim iSteps As Integer
Dim iCount As Integer
Dim fXMin, fYMin, fXMax, fYMax, fX3, fY3 As Integer
Dim Sourcedat, Sourcefld As String


Private Sub Add_Click()
'fX1 and fY1 variable equals the value in the X and Y coord textbox
fX1 = Val(X.Text)
fY1 = Val(Y.Text)
fZ1 = 0
iSteps = Val(Steps.Text)
fY2 = fY1

'Steps text box cannot be changed and uses disabled text colour
Steps.Locked = True
Steps.BackColor = &H80000011

'The create command box is available for user
Create.Enabled = True

'Whole circle divided by lines
iAngle = 360 / iSteps

' Converts anges into degrees
fRadians = (iAngle * 3.1415926) / 180

'Loops until reaches number of lines user has inputted
For iLoop = 0 To iSteps - 1

'Equations for X and Y axis for circle to be created
fX2 = (Cos(iLoop * fRadians) * fX1)
fZ2 = (Sin(iLoop * fRadians) * fX1)

'Creates cross for points
Picture1.Line (fX1 - 3, fY1 - 3)-(fX1 + 3, fY1 + 3), QBColor(5)
Picture1.Line (fX1 - 3, fY1 + 3)-(fX1 + 3, fY1 - 3), QBColor(5)

'Prints values of the variables into file 1
Print #1, fX2, fY2, fZ2

'Loop Again
Next iLoop

'Prints old values of variables into file 1
Print #1, fX1, fY1, fZ1

'Counts how points are entered
iCount = iCount + 1

'Create a line to each point
If iCount > 1 Then
Picture1.Line (fX1, fY1)-(fX3, fY3), QBColor(6)
End If

'Validating so that values do not go out of bounds of Axis
If Val(X.Text) > 200 Then
MsgBox ("Enter a value between 1 to 200 only!, Restarting!")
Call Clear_Click

ElseIf Val(Y.Text) > 200 Then
MsgBox ("Enter a value beteen 1 to 200 only!, Restarting!")
Call Clear_Click

'Msg box will appear if user has entered more then 360
ElseIf Steps > 360 Then
MsgBox ("Enter value range of 2 to 360 only!, Restarting!")
Call Clear_Click
End If

'Is used for making line to points
fX3 = fX1
fY3 = fY1
End Sub

Private Sub Clear_Click()
'Closes all disk files
Reset

'Refreshes the picture 1
Picture1.Refresh

'Calls Form_Activate Sub
Call Form_Activate

End Sub

Private Sub Exit_Click()
'Closes the program
End

End Sub

Private Sub Form_Activate()
'Variables is used to allow user to choose the location of files

Sourcefld = InputBox("Enter FLD File Name, Dont forget the .fld", "Enter FLD File Name")
Sourcedat = InputBox("Enter Data File Name, Dont forget the .dat, Enter Dat File Name")

'Opens file source
Open Sourcedat For Output As #1

'Opens file so data can be entered into file
Open Sourcefld For Output As #2

'Declares values of text boxes
X.Text = 0
Y.Text = 0
Steps.Text = 6
Create.Enabled = False
Steps.Locked = False
Steps.BackColor = &H80000005
fX3 = 0
fY3 = 0

'Code used from Peter Wilson GraphEx1 Code but altered
'Set window bounds
fXMin = -20
fXMax = 220
fYMin = -20
fYMax = 220
Picture1.ScaleWidth = fXMax - fXMin
Picture1.ScaleHeight = fYMin - fYMax
Picture1.ScaleLeft = fXMin
Picture1.ScaleTop = fYMax

'Set Axes dimensions
fAXMin = 0
fAXMax = 200
fXStep = 50
fAYMin = 0
fAYMax = 200
fYStep = 50

' Draw the Axes.
Picture1.Line (fAXMin, 0)-(fAXMax, 0) 'X-Axis
Picture1.Line (0, fAYMin)-(0, fAYMax) 'Y Axis

' Annotate +ve X-Axis
For iX = fXStep To fXMax Step fXStep
Picture1.Line (iX, 5)-(iX, -5)
Picture1.Print iX
Next iX

' Annotate +ve Y-Axis
For iY = fYStep To fYMax Step fYStep
Picture1.Line (5, iY)-(-5, iY)
Picture1.Print iY
Next iY

End Sub

Private Sub Create_Click()
'All information to be entered
Print #2, "# AVS field file"
Print #2, "ndim = 2"
Print #2, "dim 1 ="; Val(Steps.Text) + 1
Print #2, "dim 2 ="; iCount
Print #2, "nspace = 3"
Print #2, "data = double"
Print #2, "field = irregular"
Print #2, "coord 1 file ="; Sourcedat; " "; "filetype = ascii; Skip = 0; offset = 0; stride = 3; "
Print #2, "coord 2 file ="; Sourcedat; " "; "filetype = ascii; Skip = 0; offset = 1; stride = 3; "
Print #2, "coord 3 file ="; Sourcedat; " "; "filetype = ascii; Skip = 0; offset = 2; stride = 3; "
Print #2, "variable 1 file ="; Sourcedat; " "; "filetype = ascii; Skip = 0; offset = 1; stride = 3; "

End Sub

 
Replies continue below

Recommended for you

==> Could anyone plz REWORD the following code (not comments) but still functions in exactly the same way as expressed below.

Why?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor