|
yes you are correct ... silly me.
"People who never make mistakes, never do anything."
My Blog
|
|
|
|
|
I'm trying to string several arrays together. Here is my code.
<br />
public void OnCreateMessage(string TermID, string AddressLine, string MessageText)<br />
{<br />
private byte[] HeaderBegin = new byte[]{0xFF, 0x00, 0xAA, 0x55, 0x00, 0x1E, 0x48, 0x02, 0x00, 0x01, <br />
0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, <br />
0x08, 0xD2, 0x00, 0x00, 0x00, 0x00};<br />
private byte[] HeaderEnd = new byte[]{0x55, 0xAA, 0x00, 0xFF};<br />
<br />
Encoding enc = Encoding.ASCII;<br />
uint nTermID = (uint)Encoding.ASCII.GetByteCount(TermID);<br />
uint nAddressLine = (uint)Encoding.ASCII.GetByteCount(AddressLine);<br />
uint nMessageText = (uint)Encoding.ASCII.GetByteCount(MessageText);<br />
string sMyMsg = TermID+ASCII.CR+ASCII.LF+AddressLine+ASCII.CR+ASCII.LF+MessageText;<br />
byte[] myBytes = enc.GetBytes(sMyMsg);<br />
byte[] MyMsg = new byte[30+nTermID+nAddressLine+nMessageText+4];<br />
<br />
MyMsg = HeaderBegin;<br />
myBytes.CopyTo(MyMsg, 26);<br />
HeaderEnd.CopyTo(MyMsg, MyMsg.Length);<br />
However when I step thru my code there is nothing in the MyMsg. Am I doing something wrong?
Thanks for any suggestions.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
RTFM
The second parameter of the CopyTo method is the destination position, not the length.
---
b { font-weight: normal; }
|
|
|
|
|
ah..okay...That's what I'm doing,
first I move in headerbegins. 26 bytes in length.
then I move in myBytes which is a byte array of ASCII text, into MyMsg at postion 26.
Then I copy in HeaderEnd into MyMsg at the current length of MyMsg.
Is this wrong?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote: Then I copy in HeaderEnd into MyMsg at the current length of MyMsg.
I think that's the problem. You are trying to copy elements starting from one past the last element in the array. MyMsg.Length doesn't represent the actual number of elements in that array, it's always fixed and is equal to the array size.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Yeah I see that..... I changed my code to this...
<br />
byte[] MyMsg = new byte[HeaderBegin.Length+myBytes.Length+HeaderEnd.Length];<br />
<br />
HeaderBegin.CopyTo(MyMsg, 0);<br />
myBytes.CopyTo(MyMsg, 26);<br />
HeaderEnd.CopyTo(MyMsg, MyMsg.Length+2);<br />
and I get an error saying that I do not have enough elements in my array. So how do I size my byte array to handle all of the different arrays that I need to copy into it?
Will bytesread give me a value that will resize my array correctly?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi all,
a simple question.
i need to invoke a gui from a program. i can simply do
Application.Run(myForm);
the gui is started but the problem is how do i come to the next line of the code?
regards,
rnv
|
|
|
|
|
Are you tring to load a form from your main app? To do this you do something like.
NewForm newform = new NewForm();
newform.ShowDialog();
Once it it shows the form then in NewForm dialog in LoadForm you can have it start the next line of code you want.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
thanks,
here is what i want. i have the main class which should invoke certain Form at certain moment.
when i do
1. NewForm newform = new NewForm();
2. newform.ShowDialog();
3. DisplayStatusInfo("Form Displayed");
it shows the dialog but it does not do the next step (3).
any idea?
regards,
rnv
|
|
|
|
|
So I'm not really sure what board this belongs on, because it could be an issue with one of many things(ASP, XP itself, the VSTO document), so I figure here might be as good a place as any to start. Feel free to point me elsewhere though.
I've written an excel VSTO client, that is being spawned by a webclient. On my local machine and the machine of the developer that was programming the webclient, everything works just fine. The problem is we can't get it to work on any other machine. We've set up the .Net permissions, and all the code is compiling fine, but upon trying to spawn the VSTO document on anyone else's machine, I get this:
Error: Request for the permission of type
‘System.Security.Permission.SecurityPermission, mscorlib
Version=2.0.0.0, Culture=neutral, PublicKeyToken = b77a5c561934e089’
Failed
Obviously, I've missed some configuration toggle that VSTO/VS.NET/Something automatically did for me, but I'm stumped as to what. If anyone knows why this is happening(I know its a security issue, but I thought I'd given it permission), and can point me in the right direction, it would be greatly appreciated
|
|
|
|
|
I am getting this error message:
Visual Studio cannot start debugging because the debug target 'C:\...\.viewPDF.exe' is missing. Please build the project and retry, or the outputpath and assemblyname properties appropriately to point at the correct location for the target assembly.
Its such a silly problem, because I have to rebuild everytime before running my application, why do you think?
|
|
|
|
|
|
cassie1 wrote: I am using visual studio C# 2005 and cannot get the code below to work i keep getting an error unable to find filename(C:/Program Files/Bernie/Accounts.xls,
you're using unix slashes not dos slashes in your path.
|
|
|
|
|
Thanks for reply dan but ive tried other way still wont work it will build with the code ive put forward.and the path is right because it works with a different code in visual studio 2005 express okay.
|
|
|
|
|
Does the error message contain the path that it's trying to use? Does that correspond to where the file is stored?
---
b { font-weight: normal; }
|
|
|
|
|
|
Are you sure? What does the error message look like?
---
b { font-weight: normal; }
|
|
|
|
|
guffa thanks for help but ive found it i hadnt put a full stop in xlapp visible true.
|
|
|
|
|
|
Michael yes have tried that no joy
|
|
|
|
|
|
Hi,
In one windows form i.e. form1 I have a public variable (i.e. variable1) where it gets set to "hello"
in the other form i.e. form2 , I would like to get the value of the variable1 in form1 (i.e. form1.variable1)
how is this done please?
Thanks
|
|
|
|
|
First, don't make fields (what you call a public variable) public. They should never be exposed outside the class or its derivatives. If you do that you shoot a very large hole through the concept of encapsulation. Here are some more reasons why you should make fields private and not public[^]
Secondly, and to answer your questions: Here is an article on passing values between forms in .NET[^]. It will show you good techniques to do this.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
hi to all,
does any body knows how can i add a check box to data grid (c# win form)
i would appreciate if someone can suggest any link, articles or samples
best regards and thanks in advance
fady
|
|
|
|
|
I don't know exactly how to do it. But I can give u some limks that can be helpful to u
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/wnf_CustDataGrid.asp
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx
And the other is ASP.NET article, if u can get idea from it
http://www.datagridgirl.com/rowselector.aspx
Regards,
Sandy Sekhon
|
|
|
|