Help converting a vb6 function to vbnet.

S

Sara

Hello,

I am new to vbnet and have only worked with text files thus far. I've
converted the ENC() & Encode() calls from this function already. Any
help would be much appreciated.

=========
Private Sub uuencode(ByVal filename1 As String, ByVal filename2 As String)
Dim portion_size As Integer

portion_size = 45

'open the original file as binary read
Open (filename1) For Binary Access Read Shared As #1

'open the target file as binary write
Open (filename2) For Binary Access Write As #2

'for standard uuencode compatibility
Put #2, , "begin 644 " + plain_filename(filename1) + vbCrLf

'total number of full sized portion with "portion_size" bytes
total = LOF(1) \ portion_size

'remain hold the remaining bytes toward end of file
remain = LOF(1) Mod portion_size

'prepare instring to read "portion_size" bytes at a time
instring = String(portion_size, 0)

'current file position
current = 1

'for loop to read the portion one by one

For i = 1 To total
Get #1, current, instring

'use the ENC() for standard uuencode compatibility, pad "M"

Put #2, , ENC(portion_size) + Encode(instring) + vbCrLf
current = current + portion_size
Next

instring = String(remain, 0)

'get the remaining bytes toward end of the file
Get #1, current, instring$

'get the remaining bytes size and calculate ENC() for the last line

Put #2, , ENC(LOF(1) - current + 1) + Encode(instring) + vbCrLf

Close #1

'put "end" for standard uuencode compatibility

Put #2, , ENC(0) + vbCrLf + "end" + vbCrLf
Close #2
End Sub
 
A

Armin Zingler

Am 02.06.2010 04:10, schrieb Sara:
Hello,

I am new to vbnet and have only worked with text files thus far. I've
converted the ENC() & Encode() calls from this function already. Any
help would be much appreciated.

=========
Private Sub uuencode(ByVal filename1 As String, ByVal filename2 As String)
Dim portion_size As Integer
[...]

I can't offer a translation service here. ;-) BTW, all microsoft.public
groups will be closed within the next days, weeks or month.

To upgrade code, one should know the source and destination language.
I guess you will want to write more VB.Net code. Therefore I suggest
you'll study the documentation about file I/O, first. Then you'll also
be able to translate your function.

"File and Stream I/O":
http://msdn.microsoft.com/en-us/library/k3352a4t(VS.90).aspx

I'm pretty sure you'll find such a function in the WWW, however
I'll give some hints:
portion_size = 45

'open the original file as binary read
Open (filename1) For Binary Access Read Shared As #1

- Use an IO.FileStream for file access. You can also pass the access level
to it's constructor.
- Use a BinaryWriter or a StreamWriter to write into the stream.
- Use a BinaryReader or a StreamReader to read from the stream.
- A Streamwriter can use a specificed (text) encoder to write
Strings into the file. Use System.Text.Encoding.ASCII in this
case. An alternative is implementing your encoder as a
sub class of System.Text.Encoding.
'open the target file as binary write
Open (filename2) For Binary Access Write As #2

'for standard uuencode compatibility
Put #2, , "begin 644 " + plain_filename(filename1) + vbCrLf

'total number of full sized portion with "portion_size" bytes
total = LOF(1) \ portion_size

LOF() -> FileStream.Length
 
S

Sara

Armin said:
Am 02.06.2010 04:10, schrieb Sara:
Hello,

I am new to vbnet and have only worked with text files thus far. I've
converted the ENC() & Encode() calls from this function already. Any
help would be much appreciated.

=========
Private Sub uuencode(ByVal filename1 As String, ByVal filename2 As String)
Dim portion_size As Integer
[...]

I can't offer a translation service here. ;-)

Heh, whatever.<g> I figured it out, and now have a nice VB2010 Uuencode
class. Of which, not much exists out there other than 3rd party controls
that often choke when using the 4.0 framework.

Anyway, thanks for your help, and have a nice day.

~Sara
 
J

JB

Armin said:
Am 02.06.2010 04:10, schrieb Sara:
Hello,
I am new to vbnet and have only worked with text files thus far. I've
converted the ENC() & Encode() calls from this function already. Any
help would be much appreciated.
=========
Private Sub uuencode(ByVal filename1 As String, ByVal filename2 As String)
        Dim portion_size As Integer
[...]
I can't offer a translation service here. ;-)

Heh, whatever.<g> I figured it out, and now have a nice VB2010 Uuencode
class. Of which, not much exists out there other than 3rd party controls
that often choke when using the 4.0 framework.

Anyway, thanks for your help, and have a nice day.

~Sara

Hi Armin,

You said that all microsoft.public groups will be closed shortly.
Do you know why and any potential replacement?

Thanks
JB
 
C

CSquared

Armin said:
Am 02.06.2010 16:58, schrieb JB:

It's been announced in all groups. In this group the last time on May 19st, 15:48 UTC.

http://groups.google.de/group/micro...nguages.vb/browse_frm/thread/3d4b2b1990b8751a
I'm such a newbie at VB and such a recent discoverer-of/lurker-in this
group I'm really rather hesitant to say anything at all about this.
However, I can't help but wonder why, to the best of my knowledge, no
one has suggested just moving to something like alt.comp.lang.vb if
continuing this group without the help of Microsoft is going to be a
problem?

BTW, I've really enjoyed reading this group so far, and I think I've
learned a few things. I'm really disappointed to discover that its
going to go away. As far as I'm concerned, newsgroups are still one of
the most useful features of the internet. Some of that opinion comes
from the really pathetic text options for web pages. I have my minimum
text size set to 14 in Firefox and it is pretty amazing how many pages
render with overlapping or truncated text as a result. Colors are a big
problem on web pages as well. I'm reading/typing this in black text on
a light green background. If you try that with web pages you'll
discover that a lot of stuff you need to see just disappears. (e.g. the
WOT colored donuts.)

I generally loathe reading text on web pages, so I tried to download and
install the NNTP bridge thing today. So far that has not gone too well,
though I suppose I'll eventually figure it out.

Later,
Charlie C.
 
J

J.B. Moreno

CSquared said:
I'm such a newbie at VB and such a recent discoverer-of/lurker-in this
group I'm really rather hesitant to say anything at all about this.
However, I can't help but wonder why, to the best of my knowledge, no
one has suggested just moving to something like alt.comp.lang.vb if
continuing this group without the help of Microsoft is going to be a
problem?

Because if there is a problem continuing the group(s) without MS, it's
not a technical issue, it's a social issue -- who will be here?
 
P

Phill W.

I'm such a newbie at VB and such a recent discoverer-of/lurker-in this
group I'm really rather hesitant to say anything at all about this.
However, I can't help but wonder why, to the best of my knowledge, no
one has suggested just moving to something like alt.comp.lang.vb if
continuing this group without the help of Microsoft is going to be a
problem?

Mainly nobody in their right mind would suggest moving into the alt.
hierarchy; There be Dragons. ;-)

However, we're all fine and dandy [back] over in
comp.lang.basic.visual.misc.
As far as I'm concerned, newsgroups are still one of the most useful
features of the internet.
Amen to that!
I generally loathe reading text on web pages, so I tried to download and
install the NNTP bridge thing today. So far that has not gone too well,
though I suppose I'll eventually figure it out.
Agreed on the web pages; it wouldn't be so bad if they just had the
words and nothing else but, of course, it's The Web, so it has to be
"Exciting" and "Pretty". Pretty awful in most cases!

The Bridge is a hideous kludge and I've not heard of anyone who's
managed to get it working properly, which is no real surprise as Our
Friends in Redmond have no interest in making it work.

Regards,
Phill W.
 
C

CSquared

Phill said:
Mainly nobody in their right mind would suggest moving into the alt.
hierarchy; There be Dragons. ;-)
Heh! Come to think of it, I'm not subscribed to any other alt groups
either. Several rec's, but no alt's.
However, we're all fine and dandy [back] over in
comp.lang.basic.visual.misc.
I had not found that one, but I'm subscribed to it now. Thanks much.
Amen to that!

Agreed on the web pages; it wouldn't be so bad if they just had the
words and nothing else but, of course, it's The Web, so it has to be
"Exciting" and "Pretty". Pretty awful in most cases! Exactly so.

The Bridge is a hideous kludge and I've not heard of anyone who's
managed to get it working properly, which is no real surprise as Our
Friends in Redmond have no interest in making it work.
I downloaded and installed it, the best I could tell. I never did
figure out how to actually use it. Since you pointed me to
comp.lang.basic.visual.misc I think I'll go see if I can uninstall it
and just forget all about it. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top