473,395 Members | 1,679 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,395 software developers and data experts.

What's wrong with this?

Dim enc As New System.Text.ASCIIEncoding
If enc.GetString(GetStr) = "GET" Then
Dim GetURL() As Byte
Sys.Marshal.Copy(pPkt, GetURL, OffsetRes + 4, 32)
WebPage = enc.GetString(GetURL) 'Mid(enc.GetString(GetURL), 1,
InStr(enc.GetString(GetURL), "HTTP"))
End If

When stepping through the code, it highlights the sys.marshal.copy... line
and then skips back up to the top. No errors etc.

pPkt is an IntPtr containing a TCP Packet. This section of code is only
called if 3 bytes come out as "GET" as a string. (I am trying to pull out
the following data to get the actual web resource being used)
Dec 19 '05 #1
3 1098

"JamesB" <ja***@spamiscrappy.puffle.co.spam.uk> wrote in message
news:43***********************@news.zen.co.uk...
Dim enc As New System.Text.ASCIIEncoding
If enc.GetString(GetStr) = "GET" Then
Dim GetURL() As Byte
Sys.Marshal.Copy(pPkt, GetURL, OffsetRes + 4, 32)
WebPage = enc.GetString(GetURL) 'Mid(enc.GetString(GetURL), 1,
InStr(enc.GetString(GetURL), "HTTP"))
End If

When stepping through the code, it highlights the sys.marshal.copy... line
and then skips back up to the top. No errors etc.

pPkt is an IntPtr containing a TCP Packet. This section of code is only
called if 3 bytes come out as "GET" as a string. (I am trying to pull out
the following data to get the actual web resource being used)


Extra info - Im actually getting an error (if i put that in a try.catch
block) of destination cannot be nothing.
So I think the problem is that my

dim GetURL() as byte

isn't actually creating an object? If so, how do I do that.
I tried dim GetURL() as new byte, and a few other combinations but all give
compliation errors.
Dec 19 '05 #2

JamesB wrote:
So I think the problem is that my

dim GetURL() as byte

isn't actually creating an object? If so, how do I do that.
I tried dim GetURL() as new byte, and a few other combinations but all give
compliation errors.


Well, it's in the docs, but in short: Array variables in VB.NET are
object variables, so like any other object variables they are Nothing
until you give them something to point to. There are a number of ways
to actually *define* arrays but what you want is probably just

Dim GetURL() As Byte = New Byte(100) {}

where 100 is how long you want the array to be (small gotcha here). The
{} is the array initializer which here is empty which will result (for
an array of Byte) in an array full of 0s.

--
Larry Lard
Replies to group please

Dec 19 '05 #3

"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Well, it's in the docs, but in short: Array variables in VB.NET are
object variables, so like any other object variables they are Nothing
until you give them something to point to. There are a number of ways
to actually *define* arrays but what you want is probably just

Dim GetURL() As Byte = New Byte(100) {}

where 100 is how long you want the array to be (small gotcha here). The
{} is the array initializer which here is empty which will result (for
an array of Byte) in an array full of 0s.


Hmm, embarassingly I had read that somewhere but it obviously didn't sink
in.
I'm now getting that the data extends beyond the end of the array (that will
be your gotcha) so I have something to play with.
Thanks for simplifiying it!
James.
Dec 19 '05 #4

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

Similar topics

3
by: Mike Henley | last post by:
I first came across rebol a while ago; it seemed interesting but then i was put off by its proprietary nature, although the core of the language is a free download. Recently however, i can't...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
28
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr();...
9
by: Pyenos | last post by:
import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS= DEFAULT_PROGRESS_DATA_FILE="progress_data" PROGRESS_OUTCOMES=
3
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when...
89
by: Tubular Technician | last post by:
Hello, World! Reading this group for some time I came to the conclusion that people here are split into several fractions regarding size_t, including, but not limited to, * size_t is the...
20
by: Daniel.C | last post by:
Hello. I just copied this code from my book with no modification : #include <stdio.h> /* count characters in input; 1st version */ main() { long nc; nc = 0;
24
by: MU | last post by:
Hello I have some code that sets a dropdownlist control with a parameter from the querystring. However, when the querystring is empty, I get an error. Here is my code: Protected Sub...
2
by: mingke | last post by:
Hi... So I have problem with my if condition..I don't know what's wrong but it keeps resulting the wrong answer.... So here's the part of my code I have problem with: for (i=0; i<size2;...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.