|
Why did you set the textbox as the labels parent? There's no need to do this. All you have to do is call the labels BringToFront method to get it sit on top of other controls.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
while(flag == 0)
{
if(eq[i]=='0' || eq[i]=='1' || eq[i]=='+' || eq[i]=='\'') // the exception is here
{
switch(eq[i])
{
case'1':
{
if (!operator_flag)
{
new_equation[i] = 2;
new_equation[i+1] = 1;
...etc}
else
{
MessageBox.Show("Not Boolean Equation" );
flag = 1;
}
i++;
}
I got unhandled exception in the first if statement and i don't know what to do about it, can anyone give any help!!
thanks in advance
joly_1
-- modified at 11:06 Thursday 2nd February, 2006
|
|
|
|
|
Look at the inner exception. Or put a try/catch on the method that's calling the while loop. It'll tell you the exception type/stacktrace etc.
|
|
|
|
|
Well, i got this:
Index outside the bounds of the array.
so, what i should do about it?
joly_1
|
|
|
|
|
joly_1 wrote: Index outside the bounds of the array.
It means that you were trying to access element through an index and your array object was not large enough.
e.g.
string[] nameOfFriends = new string[2];
nameOfFriends[0] = "Mike";
nameOfFriends[1] = "John";
nameOfFriends[2] = "David";
I think error occurs at the following lines.
new_equation[i] = 2; <br />
new_equation[i+1] = 1;
Insert the following line before these two lines:
MessageBox.Show(string.Format("Array Length: {0}; I: {1}; I+1: {2}; Will Cause Error? {3}", new_equation.Length.ToString(), i.ToString(), (i+1).ToString(), (i>=new_equation.Length).ToString()));<br />
new_equation[i] = 2; <br />
new_equation[i+1] = 1;
|
|
|
|
|
Make sure the index does not exceed the array bounds. If you expect this never to happen then put in an assert statement after the while. If you get the assertion failure then you've got a bug.
Otherwise extend the while statement
while (flag == 0 && i < array size)
...
Kevin
|
|
|
|
|
well, also i made tha tchange in the while loop, but i still have the same exception in the same place, the if statement, it made me feel carzy about it.
this the all what i did:
Str = textBox1.Text;
eq = Str.ToCharArray();
new_equation = new int[2*Str.Length];
while(flag == 0 && i
|
|
|
|
|
joly_1 wrote: so, what i should do about it?
Check your index bounds :p
you need to check whether i lower than the array-length .
Usually you do this in a for-loop:
for(int i=0; i<myarray.Length; i++)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you all, i solved the problem , thanks alot for your advices
joly_1
|
|
|
|
|
Imagine a 60 lined text File.
i wanna add a word to 45th line
then i wanna add another word to 13th line
then i wanna add another word to 28th line
All numbers is random. How can achive that?
|
|
|
|
|
Given how files are stored on the hard-disk, it may be possible to insert data at random position into a file.
How the files are actually stored is determined by the filesystem used.
That means, unless you are writing very specific code for one filesystem, it is almost impossible to insert data at random positions.
There is, of course, a solution to this problem:
Rewrite the file. Read it, manipulate and save it, delete the original file and rename the output-file you just wrote.
If you need to do a lot of file manipulations, check if a database would not be a better approach. If you are certain that it is not, try to delay all manipulations. That is, write a buffer which will contain all changes not yet written to a file and which will "reroute" all read and write request to those positions to a memory location, not the file.
Then - maybe every 5 minutes - commit these changes to the disc.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
You'll have to read the entire file and rewrite it. During which you'll have to pause, write out the string you want to insert, then resume rewriting the file 'til the end.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have got the client site pointer in C# using
Type typeIOleObject = this.GetType().GetInterface("IOleObject", true);
//call the method on that interface
oleClientSite = typeIOleObject.InvokeMembe("GetClientSite",
BindingFlags.Instance|BindingFlags.InvokeMethod|BindingFlags.Public,null, this, null);
where this is System.Windows.Forms.UserControl
now i want to marshal that object oleClientSite to send it to another thread.
in C++ we use CoMarshalInterThreadInterfaceInStream to convert that interface to stream and send that stream to another thread where we call CoGetInterfaceAndReleaseStream to get interface pointer from that stream.
i want the alternative for that in C#, that how can i marshal that interface and get that in the other thread.
one way is to use win32 API in C# but i am getting error using this in C#.
HRESULT CoMarshalInterThreadInterfaceInStream(IN REFIID riid, IN LPUNKNOWN pUnk,OUT LPSTREAM *ppStm);
in C# i have used this as
[DllImport("Ole32.dll")]
public static extern IntPtr CoMarshalInterThreadInterfaceInStream(
Guid riid,
[MarshalAs(UnmanagedType.IUnknown)]
object pUnk,
out object ppStm);
but it returns the error code -2147024809 which means that "The parameter is incorrect".
can someone plz tell me whats the alternate for CoMarshalInterThreadInterfaceInStream and
CoGetInterfaceAndReleaseStream in C#
or how can i make that dllimport call correct
thanx in advance.
|
|
|
|
|
I want to use VI in a context menu, but it doesn't seem to work.
In my base class I have a context menu, which is set to protected.
In my derived class designer, I can see the context menu and add things to it.
When I compile the code and show the context menu, only the original items appear.
In the derived class' InitializeComponent function, I can see the new menu item being created, but it never gets attached to the base class context menu.
Is this a bug in VS2005?
I can bypass this problem by desiging a seperate context menu and adding it to the base class during the constructor, but it doesn't feel quite right to me.
Am I doing something else wrong?
Neil
No sharp objects, I'm a programmer.
|
|
|
|
|
I need to write an addin for outlook that grabs the text string from the subject box in a reminder and copies that code to a notepad file. For example when the reminder is executed the addin will write the subject text to a file. I need this addin for part of my project, does anyone know where i can get some code to do this for me or has anyone got any ideas on how to write the code for this??? Any help would be greatly appreciated.
|
|
|
|
|
hi guys,
i need to autostart my c# windows application upon boot time of the pc. is it possible using windows service? if not, what are other ways of doing it? tnx...
|
|
|
|
|
Lot of ways...
(*) You can have a shortcut to the application in the Users->Startup folder in STart Menu or (AllUsers -> Startup folder, to affect all users. I think for the latter you need to have Administrative Privileges on the system).
(*) You can have a entry in HKLM->Sofware->Microsoft->Windows->CurrentVersion->Run
(*) You can configure your application as a Windows Service itself. Developing a Windows Service in C# and deploying them is a breeze. A lot of samples anyway.
I think the first two are logon based. Some user should logon for the app to launch. The latter, by virtue of being a Windows Service, would start immediately on system boot.
Vasudevan Deepak Kumar
Personal Web: http://www.lavanyadeepak.tk/
I Blog At: http://deepak.blogdrive.com/
|
|
|
|
|
thanks for the immediate response. when i will develop a windows service, is it possible to have a method from the service that will call a c# windows app to run? i need this because i need to generate message prompts to the users in the network... i know with the other two methods, i can do this, but im not sure if it can be done using windows service and another c# app. tnx
|
|
|
|
|
I think you can run an application from a service, but usually the service will not have the right to interact with the desktop, so expect your WindowsForms application to crash as soon as it tries to open a window.
Regards,
mav
|
|
|
|
|
What about the autoexec.bat file
|
|
|
|
|
You mean placing a call to a .NET application inside autoexec.bat?
One word: Don't.
The solutions given so far are about the only options you have available. First you have to decide whether you want your program to run when the system is started (then use a service) or if you want it to run when a user logs in (then you can use the other two methods).
But nevertheless, for a windows service to run nobody has to be logged on so you usually don't have a desktop to perform user interaction with.
You _can_ allow a service desktop interaction, though.
But allowing this is usually considered bad style.
Regards,
mav
|
|
|
|
|
|
You can also try to
- use Win.ini (from good Win 3.11 times)
- write a Windows Explorer extension that starts your application
- replace a process used by the system with a modified version. On XP, you need to disable system restore for this.
- find more strange autostart locations
|
|
|
|
|
Daniel Grunwald wrote: - replace a process used by the system with a modified version. On XP, you need to disable system restore for this.
This solution will break on 64 bit windows. To stymie rootkit authors it'll no longer be possible to replace/modify OS runtime files without convincing MS you can't do it any otehr way and getting them to digitally sign your files.
|
|
|
|
|
if i remember well, if u add your program to program files/startup, it will start once with windows...
|
|
|
|