|
i am tryin to convert a project that was made in 6.0 to .net and its a little tough. I was wondering if anyone knew of a way to mimic the function of the varptr in some way.
i have been trying to use the RTLmoveMemory dll call but in .net it is almost impossible to make it function. So i have been working to figure out how this function actually works. I would say i have it almost 75 percent pinned but when you send negative numbers to it comes back with numbers that i havent been able to put a mathmatical equation too. If there is any help with that it would be great.
Public Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
but anycase i need to know how to use the varptr function because in the following snippet heres the problem and the reason i need to use it
<br />
For i = 0 To (ROUNDS + 1)<br />
dataX = 0<br />
For K = 0 To 3<br />
Call CopyMem(ByVal VarPtr(dataX) + 1, dataX, 3)<br />
dataX = (dataX Or Key(j))<br />
j = j + 1<br />
If (j >= KeyLength) Then j = 0<br />
Next<br />
m_pBox(i) = m_pBox(i) Xor dataX<br />
Next
rounds = 16
key contains a unicode work "text1"
key(0) = 116
key(1) = 101
key(2) = 120
key(3) = 116
key(4) = 49
when it first interates through the second for loop datax = 116
which is the first number in the byte array
but i have no idea where these other numbers are coming from
2 datax = 298313
3 datax = 7632253
4 datax = 1953856893
if i can figure out what varptr(datax) + 1 does and mimic its function and also figure out why when negative numbers are send to the api call it sends back really negative large numbers. Any help with any thing seen here would be awesome. thank you very much
|
|
|
|
|
VarPtr has no equivelent in VB.NET... All it does is return the address of the variable, which, in managed code, is not guarenteed to stay where it was created thereby invalidating the return of VarPtr.
What you would have to do is, in VB6, step through this code and watch what happens to dataX. the variable dataX looks like it is a Long, or Integer in VB.NET...a 32-bit signed integer. What it looks like it's doing is copying bytes 2, 3, and 4 to byte 1 of dataX. It might help to look at the value of dataX in the Watch window in Hexadecimal.
dataX before CopyMem dataX after CopyMem
byte1 | byte2 | byte3 | byte4 byte1 | byte2 | byte3 | byte4
2B 1A 00 FE 1A 00 FE FE
In this case, what you would need to do is mask out byte 1, 2, and 3 to get the value of the 4th byte. Then move the numbers in dataX to the left by 8 bits and finally add back in the lastByte:
' From the example above...
Dim dataX As Integer = &H2B1A00FE
Dim lastByte As Integer = (dataX And &H000000FF) ' lastByte will equal &HFE.
' This moves the data left 8 bits. This will drop the first byte and move
' the remaining bytes to the left, leaving 00 in the last byte.
' 2B1A00FE becomes 1A00FE00
dataX = dataX * 256
' Now add back in, the byte that we saved above.
' 1A00FE00 becomes 1A00FEFE
dataX = dataX + lastByte
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Im my VB.NET application, I'm using a custom dll that was written in VC++ 6.0.
When making calls to this dll from VB.NET 2003, I'm have allot of difficulty with the data types between VC++ and VB.NET.
The following function prototype is in the dll.
int32 dummyFunction( int* variable1, customDataStructType1* variable2, char[7], customDataStructType2, **variable3)
Any suggestions on what the call from VB.NET would look like? Or perhaps a link to a MSDN webpage?
Ideally, I would like to make a VB Structure or Class for customDataStructType1 and customDataStructType2, but not sure how to pass the data from that C Structure back to VB STruct or Class??
Thanks.
|
|
|
|
|
Is it possible to hide a specific column?
( when you have 5 columns, only display 4 of them)
Shin
|
|
|
|
|
The standard ListView doesn't support hiding columns. You have a couple of options.
You could extend the ColumnHeader class to include a Hidden proerty, then you would have to ownerdraw the ListView control draw the columns and items based on the Hidden property.
You could just make the width of the hidden column 0, but that doesn't mean that the user can't just resize the column to show the hidden column again.
You could avoid putting the hidden data into the Item.SubItem() collection. And instead, put the data into a seperate array, but keep the array index linked to the item index in the ListView:
ListView.Item() SubItem(0) SubItem(1) SubItem(2) | HiddenData()
(0)"Item1" "SI1" "SI2" "SI3" | (0)"HideMe"
(1)"Item2" "SI1" "SI2" "SI3" | (1)"HideMe"
(2)"Item3" "SI1" "SI2" "SI3" | (2)"HideMe"
(3)"Item4" "SI1" "SI2" "SI3" | (3)"HideMe"
This way, when ever the user selects an Item, say index 2, your hidden data will be in the array HiddenData(2).
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I was thinking everytime I change the size of dialog, I change the column and whole list view width so that you don't see the last column of ListView.
what do you think?
|
|
|
|
|
I've got an issue with trying to select a value from a combo box, using code.
I have a form that opens up, with a bunch of controls. This form represents a record in a table. I'm currently using a dataset to go and get that data, and then populating the controls with the individual values from that dataset.
There is a combo box on the form that is populated using an object that holds the ID of the value, and the display text. These are then assigned to the combo box as ValueMember and DisplayMember respectively.
When I ask for the SelectedValue, I get the ValueMember, which is all well and good.
However, what I want to do, is when the form loads, I want to return a dataset containing the ID that relates the ValueMember of the combo box, and select the value in the combo box that relates to that value, so that I get the corresponding DisplayMember.
I've got no idea how to do this at the moment, and it's driving me potty! Anyone...anyone... Bueller!
TIA
Tom
|
|
|
|
|
If I understand the problem correctly... You're trying to select a value in a combobox using code? Correct?
Notice that SelectedValue is a get/SET property. You can set the value of the SelectedValue property to the ValueMember that you want and it should show you the corresponding DisplayMember in the ComboBox.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks - just by writing a response, trying to show there was nothing wrong with my code, I've realised what I was doing wrong. The class I use to create an object to fill the combo box holds the ID as Long , and I was casting the value coming from the dataset as an Integer . Once I changed the cast to a Long , it worked like a dream.
I'm sorry for wasting your time!
Many Thanks
Tom
|
|
|
|
|
Good Day Every Body,
I wonder Whether any Body work on linking PC with a Machine,
I need to link a weight Indicator Machine with my PC ,
I need a result as Text File,
I don't have any Idea about Interfacing PC with Machines, through COM Port.
Please If any body can help with any small info
Lool
|
|
|
|
|
First question may seem stupid, but do you have to documentation on the interface on the scale? Without it, your going to have a tough time doing this.
Second, you'll need the proper cable to go between the PC and scale.
Third, you will need a Serial Comm class library to help you talk to the COM port. This is because there is no native .NET BCL support for serial/parallel communications. There are examples on MSDN here[^], and here[^]. There is also an example on CodeProject here[^].
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You can user Visual basic's Comm Control and then you specify port as 0 or 1.
-Prerak
|
|
|
|
|
Good Day Every Body,
Lool
|
|
|
|
|
Gooday!
Now what....???
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I've read some of the articles about using the propertygrid and it seems that i can make it work allright.
Right now i need to display a number of options and make them available for editing. For that the propertygrid seems perfect. Only problem is that i have these options in a database and it is an essential thing that the number and properties (integer,string, list selection) can be freely defined in the database. That does not seem to be compatible to the need to supply a class to the property grid.
So... can I in runtime a) change the properties of the class supplied to the propertygrid, in this way i can supply a "generic" class and live with the limitations in size or can I b) create an object virtually "bit by bit" and then supply it to the property grid ?
Kind regards
Thomas
|
|
|
|
|
Can anyone help me with any sample code for sending a SMS in VB.NET? Any help will be appreciated. This is quite urgent, I need this for a project that has to be completed soon.
|
|
|
|
|
There are TONS of examples all over the web. Just search for 'SMS message VB', or click this[^] for the results from Yahoo.
You'll need an account and password on an SMS message server service. Most sites now charge a per/message fee or have a flat fee for X number of messages per month. The 'Free' sites are not reliable enough for production use and don't always work with all phones.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Thanks for the link.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
i need to know of a way to make other variables pointers in vb.net. Is there anyway to do this. I know in 6.0 you could use the strptr or objptr or varptr. I need to know how to do this same function in .net.
|
|
|
|
|
Everything is a pointer (now called a reference) in .NET except for value-types (things like integers, booleans, floating point numbers, and so on).
I don't know how you would get a pointer in VB.NET, although you can do it in C# by creating some unsafe code - but VB.NET doesn't support the unsafe context.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
this is my initial variable:
Dim Operators() As String = {"=", "<=", ">=", "+", "-", "!="}
Dim Codes() As String = {"UC", "CT", "LS", "PR", "P1", "P2", _
"P3", "P4", "P5", "P6", "P7", "P8", "P9", "PQ", _
"QT", "PC", "SR", "MV", "SC", "DC"}
Could someone help me to how use regular expression to check an input of string is valid in the following order:
Codes Operators Integer
For example: UC = 3
Thanks.
John
|
|
|
|
|
Hi John. How about this regular expression?
^(UC|CT|LS|PR|P1|P2|P3|P4|P5|P6|P7|P8|P9|PQ|QT|PC|SR|MV|SC|DC)\s*(=|<=|>=|\+|-|!=)\s*\d+$
- The initial
^ makes the match at the beginning of the string (i.e. nothing can come before the code). - Next is a group of choices (your codes) surrounded by (parentheses) and seperated with vertical bars |.
- The
\s that follows means to match white space and the asterisk * says "zero or more times"... so the \s* allows for optional white space between the code and the operator. - Then the (=|<=|>=|\+|-|!=) group is another list of choices, seperated by
| , surrounded by (...) like before. The + sign has special meaning in regular expressions, so it requires an escape backslash \ character in front of it to treat it as a literal + sign. - Next we have another
\s* , again allowing for optional whitespace between the operator and the integer - We use
\d+ to match one or more digits from 0 to 9... the \d means match a digit, and the + means "one or more times". - Finally, the
$ dollar sign at the end matches the position at the end of the input string, meaning that no other characters may follow the digits.
I hope this helps.
|
|
|
|
|
Thank you so much. This really helps.
John
|
|
|
|
|
I have list of document of type word,pdf and tif images. When open the documents and print , i expect the printing resulted in the same order.
But the word documents are printed first and then pdf and the order is not what I printed.
How to avoid this jumble and maintain the order in which i printed.
Regards
Thangavel
|
|
|
|
|