Imports in C# is ??? in VB?

  • Thread starter Thread starter Crirus
  • Start date Start date
C

Crirus

I have this :

imports (Stream s = response.GetResponseStream()) {

int nread;

do {
nread = s.Read(buffer, 0, (int)buffer.Length);
fs.Write(buffer, 0, nread);
} while (nread != 0);
}

How to write in VB this?
 
* "Crirus said:
ohh copy/paste from wrong place.. it is using..and I know that keword
meaninig

You know how to rewrite the code in VB.NET?
 
Crirus,
You will need to wait for Whidbey (VS.NET 2004 later in 2004) to support the
new Using statement, which will function as C#'s using statement.
using (Stream s = response.GetResponseStream()) {
}

For now you will need to manually wrap the block in a try finally and call
the dispose yourself.

For details on the improvements to VB.NET in Whidbey see:
http://msdn.microsoft.com/vbasic/whidbey/

Hope this helps
Jay
 
yes, I just dispose the stream when done

well, I have another one to translate

expandedBytes[pos++] = (byte)IntToHex((b >> 4) & 0xf);

Can you help?
 
Crirus,
With VS.NET 2003:

Something like:
pos += 1
expandedBytes(pos) = CByte(IntToHex((b >> 4) And &hf))

If you are confined to VS.NET 2002, I would recommend an upgrade! ;-)

Seriously with VS.NET 2002 you can use multiple or divide instead of the
shift operators.

pos += 1
expandedBytes(pos) = CByte(IntToHex((b \ 16) And &hf))

Hope this helps
Jay

Crirus said:
yes, I just dispose the stream when done

well, I have another one to translate

expandedBytes[pos++] = (byte)IntToHex((b >> 4) & 0xf);

Can you help?
 
* "Crirus said:
yes, I just dispose the stream when done

well, I have another one to translate

expandedBytes[pos++] = (byte)IntToHex((b >> 4) & 0xf);

Instead of '&', use 'And'. If you use VB.NET 2003, you will have a '>>'
operator too. What's the problem?
 
Is true pos+=1 is before the
expandedBytes(pos) = CByte(IntToHex((b >> 4) And &hf)) ?


--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

Jay B. Harlow said:
Crirus,
With VS.NET 2003:

Something like:
pos += 1
expandedBytes(pos) = CByte(IntToHex((b >> 4) And &hf))

If you are confined to VS.NET 2002, I would recommend an upgrade! ;-)

Seriously with VS.NET 2002 you can use multiple or divide instead of the
shift operators.

pos += 1
expandedBytes(pos) = CByte(IntToHex((b \ 16) And &hf))

Hope this helps
Jay

Crirus said:
yes, I just dispose the stream when done

well, I have another one to translate

expandedBytes[pos++] = (byte)IntToHex((b >> 4) & 0xf);

Can you help?

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

Herfried K. Wagner said:
* "Crirus" <[email protected]> scripsit:
ohh copy/paste from wrong place.. it is using..and I know that keword
meaninig

You know how to rewrite the code in VB.NET?
 
the problem still is in fact that IntToHex return a char

(byte)??


--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

Herfried K. Wagner said:
* "Crirus said:
yes, I just dispose the stream when done

well, I have another one to translate

expandedBytes[pos++] = (byte)IntToHex((b >> 4) & 0xf);

Instead of '&', use 'And'. If you use VB.NET 2003, you will have a '>>'
operator too. What's the problem?
 
Is true pos+=1 is before the
expandedBytes(pos) = CByte(IntToHex((b >> 4) And &hf)) ?

No the increment should come after since the C# code used the postfix
increment operator.



Mattias
 
Crirus,
Doh! Mattias is correct the pos+= 1 should be after the statement

Something more like (untested):
I knew I should have included "untested" in my remarks ;-)

Jay

Crirus said:
Is true pos+=1 is before the
expandedBytes(pos) = CByte(IntToHex((b >> 4) And &hf)) ?


--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

Jay B. Harlow said:
Crirus,
With VS.NET 2003:

Something like:
pos += 1
expandedBytes(pos) = CByte(IntToHex((b >> 4) And &hf))

If you are confined to VS.NET 2002, I would recommend an upgrade! ;-)

Seriously with VS.NET 2002 you can use multiple or divide instead of the
shift operators.

pos += 1
expandedBytes(pos) = CByte(IntToHex((b \ 16) And &hf))

Hope this helps
Jay

Crirus said:
yes, I just dispose the stream when done

well, I have another one to translate

expandedBytes[pos++] = (byte)IntToHex((b >> 4) & 0xf);

Can you help?

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

* "Crirus" <[email protected]> scripsit:
ohh copy/paste from wrong place.. it is using..and I know that keword
meaninig

You know how to rewrite the code in VB.NET?
 
Back
Top