473,382 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

converting to .net


How would i convert this on vb.net?

Open DestinFile For Input As #25
If LOF(25) > 0 Then
Close()
GoTo AllreadyE
End If

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
7 1306
Dim lfsTemp As FileStream
Dim lbwTemp As BinaryWriter
Dim lbTemp() As Byte

Try
lfsTemp = New FileStream("MyFileName", FileMode.Create)
lbwTemp = New BinaryWriter(lfsTemp, System.Text.Encoding.Default)
lbTemp = System.Text.Encoding.Default.GetBytes(stringFileCo ntent)
lbwTemp.Write(lbTemp)
lbwTemp.Close()
lfsTemp.Close()
lbwTemp = Nothing
lfsTemp = Nothing
Catch ex As Exception
MsgBox (string.Concat("Cannot write file, ", "MyFileName"))
End Try

"Ryan Epinos" wrote:

How would i convert this on vb.net?

Open DestinFile For Input As #25
If LOF(25) > 0 Then
Close()
GoTo AllreadyE
End If

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #2
Ryan,
How would i convert this on vb.net?


Seems like you're just checking if a file exists and has a non-zero
length, in which case you can do

Dim fi As new FileInfo(DestinFile)
If fi.Exists AndAlso fi.Length > 0 Then ...

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #3


would you guys consider this:

Before:
Open DestinFile For Input As #25
If LOF(25) > 0 Then
Close()
GoTo AllreadyE
End If

After:

FileOpen(25, DestinFile, OpenMode.Output)
WriteLine(25, "DestinFile")
If LOF(25) > 0 Then
Close()
GoTo AllreadyE
End If

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #4
AndAlso...never heard of that. Is it the same as just And?

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
If fi.Exists AndAlso fi.Length > 0 Then ...

Nov 21 '05 #5
> AndAlso...never heard of that. Is it the same as just And?

No its works differently (from msdn):

"A logical operation is said to be short-circuiting if the compiled code can
bypass the evaluation of one expression depending on the result of another
expression. If the result of the first expression evaluated determines the
final result of the operation, there is no need to evaluate the other
expression, because it cannot change the final result. Short-circuiting can
improve performance if the bypassed expression is complex, or if it involves
procedure calls."

"And" used to evaluate both expressions, "AndAlso" works as mentioned above.

Ab.
http://joehacker.blogspot.com
there are better things to discuss like :
http://www.msnbc.msn.com/id/7328143/

"Terry Olsen" <to******@hotmail.com> wrote in message
news:u3****************@TK2MSFTNGP14.phx.gbl...
AndAlso...never heard of that. Is it the same as just And?

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
If fi.Exists AndAlso fi.Length > 0 Then ...


Nov 21 '05 #6
That makes it sound a bit like the OR operator...

Except that OR probably evaluates both expressions regardless...

"Abubakar" <ab*******@gmail.com> wrote in message
news:OT*************@TK2MSFTNGP10.phx.gbl...
AndAlso...never heard of that. Is it the same as just And?


No its works differently (from msdn):

"A logical operation is said to be short-circuiting if the compiled code
can
bypass the evaluation of one expression depending on the result of another
expression. If the result of the first expression evaluated determines the
final result of the operation, there is no need to evaluate the other
expression, because it cannot change the final result. Short-circuiting
can
improve performance if the bypassed expression is complex, or if it
involves
procedure calls."

"And" used to evaluate both expressions, "AndAlso" works as mentioned
above.

Ab.
http://joehacker.blogspot.com
there are better things to discuss like :
http://www.msnbc.msn.com/id/7328143/

"Terry Olsen" <to******@hotmail.com> wrote in message
news:u3****************@TK2MSFTNGP14.phx.gbl...
AndAlso...never heard of that. Is it the same as just And?

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
> If fi.Exists AndAlso fi.Length > 0 Then ...



Nov 21 '05 #7
CT
> Except that OR probably evaluates both expressions regardless...

Correct, but you also have OrElse for shortcuiting evaluation...

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk

"Terry Olsen" <to******@hotmail.com> wrote in message
news:e$*************@TK2MSFTNGP09.phx.gbl...
That makes it sound a bit like the OR operator...

Except that OR probably evaluates both expressions regardless...

"Abubakar" <ab*******@gmail.com> wrote in message
news:OT*************@TK2MSFTNGP10.phx.gbl...
AndAlso...never heard of that. Is it the same as just And?


No its works differently (from msdn):

"A logical operation is said to be short-circuiting if the compiled code
can
bypass the evaluation of one expression depending on the result of
another
expression. If the result of the first expression evaluated determines
the
final result of the operation, there is no need to evaluate the other
expression, because it cannot change the final result. Short-circuiting
can
improve performance if the bypassed expression is complex, or if it
involves
procedure calls."

"And" used to evaluate both expressions, "AndAlso" works as mentioned
above.

Ab.
http://joehacker.blogspot.com
there are better things to discuss like :
http://www.msnbc.msn.com/id/7328143/

"Terry Olsen" <to******@hotmail.com> wrote in message
news:u3****************@TK2MSFTNGP14.phx.gbl...
AndAlso...never heard of that. Is it the same as just And?

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...

> If fi.Exists AndAlso fi.Length > 0 Then ...



Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
29
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant...
8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
2
by: Map Reader | last post by:
Greetings, I am converting an old VB6 application to use .NET. One of the old controls loads icons from the disk and displays them. However, the transparent color turns to blue somewhere in the...
12
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
7
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
4
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.