dcsimg
Results 1 to 4 of 4

Thread: loop...

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    2

    loop...

    anyone can help me.... i dont known which one is wrong code...
    Code:
    Imports Microsoft.VisualBasic
    Imports System
    
    Public Class GlobalMembersProject1
    	Shared Function Main() As Integer
    	Dim [date] As New String(New Char(14){})
    	Dim program As New String(New Char(19){})
    	Dim filename As New String(New Char(9){})
    	Dim filename2 As New String(New Char(9){})
    	Dim ans As SByte
    	Dim write As SByte
    	Dim bil As Integer
    	Dim i As Integer
    	Dim dist(9) As Double
    	Dim deg(9) As Double
    	Dim min(9) As Double
    	Dim sec(9) As Double
    	Dim brg(9) As Double
    	Dim lat(9) As Double
    	Dim dip(9) As Double
    	Const pi As Double = 3.1415926535897932384626433832795
    	again:
    	Console.Write(vbLf & " enter data filename:")
    	cin>>filename
    
    	' protocol read file
    	Dim fp1 As New ifstream()
    	fp1.open(filename)
    	 If fp1 Is Nothing Then
    	 Console.Write(vbLf & " cannot open")
    	 Console.Write(filename)
    	 Console.Write("to read")
    	 Console.Write(vbLf & " continue read file?Y/N")
    	 cin>>ans
    	 If ans = AscW("y"c) OrElse "Y"c Then
    		 GoTo again
    	 End If
    	 Return 0
    	 End If
    	Console.Write("file found")
    
    	'read data
    	 fp1>> [date]
    	 fp1>> program
    	 fp1>> bil
    
    	For i = 1 To bil
    	 fp1>>dist(i)>>deg(i)>>min(i)>>sec(i)
    	Next i
    
    	'display data on screen
    	 Console.Write(vbLf & "date:")
    	 Console.Write([date])
    	 Console.Write(vbLf & vbLf & "dist:")
    	 Console.Write(vbTab & "deg:")
    	 Console.Write(vbTab & "min:")
    	 Console.Write(vbTab & "deg:")
    
    	 For i = 1 To bil
    	 Console.Write(vbLf)
    	 Console.Write(dist(i))
    	 Console.Write(vbTab)
    	 Console.Write(deg(i))
    	 Console.Write(vbTab)
    	 Console.Write(min(i))
    	 Console.Write(vbTab)
    	 Console.Write(sec(i))
    	 Next i
    
    	fp1.close()
    
    	'write to file
    
    	'process
    	For i = 1 To bil
    		brg = deg+min/60.0+sec/3600.0
    		lat = dist *Math.Cos(brg *3.1415926535897932384626433832795/180)
    		dip = dist *Math.Sin(brg *3.1415926535897932384626433832795/180)
    	Next i
    
    	'write data to file
    	Console.Write(vbLf & "write data to file? Y/N")
    	cin>>write
    	If write = AscW("y"c) OrElse write = AscW("Y"c) Then
    		GoTo next
    	End If
    	Return 0
    	next:
    	Console.Write("enter filename output name:")
    	cin>>filename2
    
    	'protocol write to file
    	Dim fp2 As New ofstream()
    	fp2.open(filename2)
    	 If fp2 Is Nothing Then
    	 Console.Write(vbLf & " cannot write to file")
    	 Console.Write(filename2)
    	 End If
    
    	fp2<<vbLf & "date:"<<[date]
    	fp2<<vbLf & vbLf & "dist:"<<vbTab & vbTab & "brg:"<<vbTab & vbTab & "latid:"<<vbTab & vbTab & "depart:"
    
    	 For i = 1 To bil
    	 fp2<<vbLf<<dist(i)<<vbTab & vbTab & vbTab & vbTab<<brg(i)<<vbTab & vbTab & vbTab & vbTab<<lat(i)<<vbTab & vbTab & vbTab & vbTab<<dip(i)
    	 Next i
    	 Console.Write(vbLf & " file write successfully")
    	 Console.Write(vbLf & " open file output to read")
    	 fp2.close()
    	Return 0
    	End Function
    End Class
    Last edited by si_the_geek; May 6th, 2012 at 05:47 AM. Reason: added Code tags

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,365

    Re: loop...

    Welcome to VBForums

    Thread moved from the 'Database Development' forum to the 'VB.Net' (VB2002 and later) forum.

  3. #3
    Hyperactive Member jasonwucinski's Avatar
    Join Date
    Mar 2010
    Location
    Pittsburgh
    Posts
    452

    Re: loop...

    Hello, and welcome to the forum.
    Try to me more specific. what is not working? If there is an error, what is the error? what should the expected result be? What framework are you using? The more relevant information you can provide, the more help you will receive.

    Good luck and welcome!
    if i was able to help, rate my post!

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,724

    Re: loop...

    You are using a strange mix of languages there. You are using stream << operators, which are found in C++, but not in VB, as far as I know. There are other oddities to that whole thing, too, so what is the question?
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width