in your expected output you need the line starting with 1 then after wards 2. How is that organised. I mean whats the requirement for that digit? paste the loop which you are using..
Here it is. Actually my expected output like this, those Z value with same value will be classed starting from 1. For example you see that for Z value for 500 I class starting from 1 and for 460 I class it as 2 and so on.
Code:
Open Text2 For Output As #3
Base = a
Interval = Val(Text3.Text)
Dim biln As Double
Dim noContour As Integer
biln = (Zmax / Interval)
Dim q As Integer
q = 1
noContour = (biln + Val(q))
Dim c As Integer
Print #3, "X", "Y", "Z"
For c = 0 To noContour - 1
Base = a
no = 1
For Base = a To Zmax - 1
If Abs(div1) > 0.0001 Then
mu = -(XY(TIN.Node1, 2) - Base) / div1
If mu >= 0 And mu <= 1 Then
p(no).x = XY(TIN.Node1, 0) + mu * (XY(TIN.Node2, 0) - XY(TIN.Node1, 0))
p(no).y = XY(TIN.Node1, 1) + mu * (XY(TIN.Node2, 1) - XY(TIN.Node1, 1))
p(no).z = Base
Print #3, p(no).x, p(no).y, p(no).z
'Base = Base + Interval
Else
p(no).x = (XY(TIN.Node1, 0) + mu * (XY(TIN.Node2, 0) - XY(TIN.Node1, 0)))
p(no).y = XY(TIN.Node1, 1) + mu * (XY(TIN.Node2, 1) - XY(TIN.Node1, 1))
p(no).z = Base
Print #3, p(no).x, p(no).y, p(no).z
'Base = Base + Interval
End If
End If
Base = (Base + Interval) - Val(1)
If Base = Zmax Then
Print #3, p(no).x, p(no).y, p(no).z
Base = (Base + Interval)
no = no + Val(1) ' start line/end line
c = c + Val(1)
End If
no = no + Val(1) ' start line/end line
Next Base
c = c + Val(1)
Next c
Close #3
MsgBox " Contour Generated", vbOKOnly
And this what I got
X Y Z
840267.7 3170995 500
840348.8 3170966 500
840405.1 3170928 500
840459.2 3170954 500
840493.3 3170995 500
839724.9 3170983 460
839795.4 3170944 460
839890.6 3170936 460
839941.1 3170928 460
Below is the code
Print #3, "X", "Y", "Z"
Print #3, p(no).x, p(no).y, p(no).z
I want to class the z value with id . For example, All Z value contains same value will class starting from 1 untill finish. How to do that?
You want to write "," instead of blank spaces and 1 and 2 in front of your strings. Where is 1 written and where is 2, depending on what, on last three numbers?
CSTR is used for type conversion. I just used for converting the data type of (no) to string. Incase the (no) is in number format then it might throw error while treating it as string. You can remove CSTR from other fields too.
Private Sub Command1_Click()
Dim myData As String
Dim br As Integer
Open "C:\MyFile.txt" For Input As #1
Open "C:\MyFile2.txt" For Output As #2
Do Until EOF(1)
Line Input #1, myData
If (Right$(myData, 3) = "500") Then myData = "1," + myData
If (Right$(myData, 3) = "460") Then myData = "2," + myData
For br = 1 To Len(myData)
If Mid$(myData, br, 1) = " " Then Mid$(myData, br, 1) = ","
Next br
Print #2, myData
Loop
Close #1, #2
FileCopy "C:\MyFile2.txt", "C:\MyFile.txt"
Kill "C:\MyFile2.txt"
End Sub
Why there have a big space after between number and , ? There have big gaps.Can we make it closely?I also attach the files of my result
Print #3, no, ",", p(no).x, ",", p(no).y, ",", p(no).z
Why there have a big space after between number and , ? There have big gaps.Can we make it closely?I also attach the files of my result
Print #3, no, ",", p(no).x, ",", p(no).y, ",", p(no).z
Yes,Nevermind I solved it, but the problem is that, the output have gap.. How to move the , so that it my look easy such as 1 , 850938.076073618 , 3152812.34969325 , 244
Print #3, no, ",", p(no).x, ",", p(no).y, ",", p(no).z
Private Sub Command1_Click()
Dim myData As String
Dim br, x As Integer
Open "C:\MyFile.txt" For Input As #1
Open "C:\MyFile2.txt" For Output As #2
Do Until EOF(1)
Line Input #1, myData
y = 0
For x = 244 To 614 Step 10
y = y + 1
b$ = Str(y)
If (Right$(myData, 3) = x) Then
MsgBox ("radi")
myData = b$ + "," + myData
End If
Next x
For br = 1 To Len(myData)
If Mid$(myData, br, 1) = " " Then Mid$(myData, br, 1) = ","
Next br
Print #2, myData
Loop
Close #1, #2
FileCopy "C:\MyFile2.txt", "C:\MyFile.txt"
Kill "C:\MyFile2.txt"
End Sub
How to make the the output where the number and , are closely without gap. I want to output files like the first two line for all records..How to do that? Here is my code to generate the output
Code:
Open Text2 For Output As #3
Base = a
Interval = Val(Text3.Text)
Dim biln As Double
Dim noContour As Integer
biln = (Zmax / Interval)
Dim q As Integer
q = 1
noContour = (biln + Val(q))
Dim c As Integer
'Print #3, "X", ",", "Y", ",", "Z"
For c = 0 To noContour - 1
Base = a
no = 1
For Base = a To Zmax - 1
If Abs(div1) > 0.0001 Then
mu = -(XY(TIN.Node1, 2) - Base) / div1
If mu >= 0 And mu <= 1 Then
p(no).x = XY(TIN.Node1, 0) + mu * (XY(TIN.Node2, 0) - XY(TIN.Node1, 0))
p(no).y = XY(TIN.Node1, 1) + mu * (XY(TIN.Node2, 1) - XY(TIN.Node1, 1))
p(no).z = Base
Print #3, no, ",", p(no).x, ",", p(no).y, ",", p(no).z
'Base = Base + Interval
Else
p(no).x = (XY(TIN.Node1, 0) + mu * (XY(TIN.Node2, 0) - XY(TIN.Node1, 0)))
p(no).y = XY(TIN.Node1, 1) + mu * (XY(TIN.Node2, 1) - XY(TIN.Node1, 1))
p(no).z = Base
Print #3, no, ",", p(no).x, ",", p(no).y, ",", p(no).z
'Base = Base + Interval
End If
End If
Base = (Base + Interval) - Val(1)
If Base = Zmax Then
Print #3, p(no).x, p(no).y, p(no).z
Base = (Base + Interval)
no = no + Val(1) ' start line/end line
c = c + Val(1)
End If
no = no + Val(1) ' start line/end line
Next Base
c = c + Val(1)
Next c
Close #3