|
|
Hi I'm trying to convert this C# code in to VB.net
public event EventChannelMessage EventChannelMessage
{
add { m_EventChannelDataReceived += value; }
remove { m_EventChannelDataReceived -= value; }
}
Here is the converted code i got from one of the code converters but it cannot compile in VB.
Public Custom Event EventChannelMessage As EventChannelMessage
AddHandler(ByVal value As EventChannelMessage)
m_EventChannelDataReceived += value
End AddHandler
RemoveHandler(ByVal value As EventChannelMessage)
m_EventChannelDataReceived -= value
End RemoveHandler
End Event
Anyone who understand both VB and C# please help me as this needed ASAP.
Thanks in Advance.
|
|
|
|
|
Try one of the free online C# to VB.NET convertors like this one[^].
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
You need a 'RaiseEvent' block in custom events in VB:
RaiseEvent(ByVal sender As Object, ByVal e As EventArgs)
'...
End RaiseEvent
The online converters should have caught that.
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
VB & C# to Java Converter
Java to VB & C# Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++/CLI
|
|
|
|
|
Sorry, complete computer hardware novice here.
How much memory do I have for arrays?
According to system information my computer has 1.99Gigabytes of RAM
2 Gigabtyes = about 2,048,000,000 bytes
According to vb.net documentation, single precision floating point = 4 Bytes
2 Gigabytes / 4 Bytes = 512,000,000
So I figured I would try:
Dim Myarray(512000000) As Single
That didn't work, so I tried:
Dim Myarray(512000000 / 2) As Single
But that didn't work either!
How much memory do I have? How can I find out? How can I access it?
References appreciated.
Thanks in advance
|
|
|
|
|
Your math is correct but you are forgetting a few things. First is that the operating system and any programs that are running are using up some of the space. Second is that arrays need a contiguous block of memory,they can't be broken into small chunks and placed in several places. If your memory is more than one piece then the array can't be larger than the largest piece of memory and also where the operating system places programs in memory may reduce the largest block of memory.
If you actually needed to use anywere near the computer's memory limits you should make a few small arrays rather than one monster array but in any case you should try to make your arrays the minimum size necisary to do the job not the largest possible.
|
|
|
|
|
Hmmm. interesting, but it doesn't seem to matter. Large array or small arrays, the max I can ever get is about 780MB. Is this perhaps a limitation of .net?
Can I use virtual memory to increase the size of my arrays? Does that question even make any sense?
Thanks again.
|
|
|
|
|
cstrader232 wrote: Is this perhaps a limitation of .net?
No. The limit is determined by the biggest block of available memory. Also, memory not withstanding, you can only have Int32.MaxValue number of elements in an array, on a 32-bit machine.
cstrader232 wrote: Can I use virtual memory to increase the size of my arrays
This is already done automatically by .NET's memory manager and Windows. The limit is determined by the state of Windows when the array is allocated and, the amount of RAM installed in the machine, the maximum size of your systems page file, and the fact the, by default, there is a 2GB user mode limit per process.
On my machine, 3,000,000 Single's results in a VM size of 1.22GB - automatically. I can to somewhere north of about 3.05 million Singles in an array after a fresh boot, with about 1.5GB of RAM in it.
Keep in mind that your app does not have access to the entire 2GB. The system occupies a good chunk of that memory, so your code has to share that limit. The effective range you have is a max of about 1.2 to 1.4GB of memory for your application, depending on what's installed and running in the system.
|
|
|
|
|
OK, that helps although it's disappointing...
But I don't understand your comment:
"On my machine, 3,000,000 Single's results in a VM size of 1.22GB - automatically. I can to somewhere north of about 3.05 million Singles in an array after a fresh boot, with about 1.5GB of RAM in it."
I can get about 194,000,000 (194 million) singles (That is 780,000,000 bytes), but never more.
In any case, is it possible to tell what the biggest array I can dim at a given time is? I guess I need to determine the biggest block of available memory
Thanks
|
|
|
|
|
cstrader232 wrote: I can get about 194,000,000 (194 million) singles (That is 780,000,000 bytes), but never more.
Like I said, this limit will depend on how much RAM is installed in the machine, the size of the page files you have, what else is installed in Windows (drivers, services running, other applications), and how big your app is, among other things.
cstrader232 wrote: I can get about 194,000,000 (194 million) singles (That is 780,000,000 bytes), but never more.
Disable services you don't need, reboot the machine and see what happens.
cstrader232 wrote: In any case, is it possible to tell what the biggest array I can dim at a given time is?
No, not without trying to allocate the array.
From your description, you're either going to have to go to a 64-bit machine with a ton of ram, or go with doing this in files. You're going ot have more than just the 50,000,000 rows in the array. How many columns are in this array (50M x 5?? = 250,000,000).
|
|
|
|
|
OK, well, say 10 columns, so 500M singles (!).
Would you be able to recommend what might be the fastest way to read the arrays to and from disk?
Serializing and deserializing didn't seem that fast to me -- I was hoping there might be something better.
|
|
|
|
|
OK, so at least a 2GB file. Nothing about this going to be fast.
Binary files (hint: BinaryReader/BinaryWriter classes) is about the fastest you're going to get in the smallest amount of disk space.
|
|
|
|
|
What are you even doing that is going to warrant needing such a big array?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Well, in essenca I have an array with many millions of rows in it. These rows represent the daily closing (and other) prices for say 10,000 different stocks over say 20 years (20 years * 250 trading days/year). So there could be say 50,000,000 rows in the array.
Then I want to calculate, for instance, what would happen if I bought a stock when it fell below a moving average price and sold it when it went over that price. So I need to create the moving average for each stock and do some calculations.
But then, I need to do those calculations again, with a small change in the moving average (to see if that helps or hurts my profits), and then do this, again with a small change, many, many times.
The ONLY way to succeed is to hold the entire array in memory -- otherwise rereading the data from the disk on each new caculation makes everything way too slow.
|
|
|
|
|
Get a 64 bit machine load in 16gb of memory and go for it! I am surprised, most places don't retain 20yrs of data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi, could someone please help me, i am trying to copy a row from one DataGridView to another on a double click....I want the whole roe to be copied. In DataGridView1 i have an Access Database table bound to it. I got this code but it doesn't seem to work...Please Help,
Thanks!
Dim myTable As DataTable = Me.myDataSet.Tables(0)
myTable.Clear()
For Each row As DataGridViewRow In Me.dgvMain.SelectedRows
myTable.ImportRow(DirectCast(row.DataBoundItem, DataRowView).Row)
Next row
Me.myBindingSource.DataSource = myTable
|
|
|
|
|
I am trying to connect to a system using the admin id and password but i get this error (WMI)
Call was canceled by the message filter. (Exception from HRESULT: 0x80010002 (RPC_E_CALL_CANCELED))
does anyone have a clue what is this and how to get around this
|
|
|
|
|
hi,
hi i have to checkboxes in my form which are associated to two columns of table of bit value type... default they have null value..
for the select query i used isnull(col_val,0) as <alias name=""> for both columns to check the null values & replace with null
but when i save my record through adapter.update() the value not get saved into database...
what's the problem..
need help
|
|
|
|
|
It used to be that bit values could not be null depending on your database or connection this may be the case. Bit = boolean eg 1 or 0
I beleive this has changed in later versions of SQL Server but I may be wrong. If you need a 3 valued field ie Null, 0 , 1 use an interger. and use -1,0,1
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i need to check against null value if not then assign 0 or 1..
i am using sql server 2005
|
|
|
|
|
ok post your select statement becuase IsNull is the correct function to deal with this issue.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
ok here is the query....
for all values i clear the bind first then bind them thru appropriate columns... i debug all values agre going to dataget..just after adapter.update(dataset) ..value doesn't updated to database..
"select pra_key,ClientAddCode,Name,Address1,Address2,City,Country,Pin,ResTel,ResFax," & _
"ResEmail,OffTel,OffFax,OffEmail,OffExtn,Mobile,ITPAN,RegDate,isnull(IsError,0) as IsError,isnull(IsBlock,0) as IsBlock,isnull(ParentCode,'') as ParentCode,ResidentialStatus,offadd1,offadd2," & _
"offaddcountry,offaddpincode,dob,occupation," & _
"educationalqlfy, offaddcity,clientcategorycode,SubBranchCode,PoAMandate," & _
"WebXCode,FASubTypeCode,UINo,agmtsrno,state,clnttype,intfirstname,intmiddlename,intlastname," & _
"relationshipwithclient,intclientcode,offaddstate,internettrading,directclient,RMCode,SubGroupCode,poadate," & _
"bankcertificate,employeecode,contactperson,paymentprocessing,creditlimit," & _
"creditlimitamount,paymentmethod, ucccategory,ioischarges,ioholdcharges, " & _
"digitalcontracts, frontofficeupload, internettradingupload, frontofficedealer, deactivate, " & _
"deactivationdate, paymenthold, interesttype, interestjv, paymenttype, runningaccountletter, " & _
"rmsgroup, region, clientcashtosharesratio from clientaddmaster where clientaddcode=@clientaddcode"
|
|
|
|
|
This is what I would do:
1. Open SQL profiler to determine *exactly* what SQL statement is being sent to the database. If needed, you can pause the recording and turn it on just prior to running your update.
2. Open up SQL Management Studio. Copy and paste the update statement from profiler.
3. Execute the statement. Determine what part of the statement is hosed and fix it.
4. Go back to VB and correct the code to match the working statement in step 3.
Profiler will show you exactly what is being sent to and from the databases - versus you think is being sent.
|
|
|
|
|
So presumably you are building a sql string and using that in the adapter.update. Your error is fairly obvious, if you are using SQL management studio you should actually open sql profiler and look at the string that is passed to sql server.
Copy the string from the debug immediate or command window and paste it into SQL query tool and see what you get.
Hint - you must do all the data manipulation BEFORE it gets into the string, IsNull is a SQL function and you are passing it in as a string.
Suggestion - strong one, get to know stored procedures or at least parameterised queries thay will save you a lot of heartache in the future.
Actually I have no idea what would be going through as I NEVER use the adapter select/update methods.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Hint - you must do all the data manipulation BEFORE it gets into the string, IsNull is a SQL function and you are passing it in as a string.
Suggestion - strong one, get to know stored procedures or at least parameterised queries thay will save you a lot of heartache in the future.
Amen!
Stored procedures are the way to go and really are not that hard to put together. Read a couple SP guides/tutorials and you'll be on your way.
|
|
|
|
|