|
And?
What does it do that you didn't expect, or not do that you did?
Remember that we can't see your screen, access your HDD, or read your mind.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
That's JavaScript, not C#. Please take the question to a more appropriate forum.
|
|
|
|
|
That my friend seems more like a JavaScript code, so trying to write the C# code in it won't work at all.
If you really want to write the application, then please, wasting no time at all go to this documentation[^].
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hi,
I am outputting log style info into a multiline textbox. I have the vertical and horizontal scrollbar property enabled. At runtime when data is added to the multiline textbox, I can see the scrollbars but they cannot be moved.
Do I need to do something more to make them actually work?
Thanks,
Rob
|
|
|
|
|
The scrollbars should work once there is more text in the textbox than it can show, when the application is running and the textbox'Enabled property is set to "true".
A disadvantage will be the speed of adding stuff to the textbox; consider using a listbox once you encounter that problem.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I found that the textbox Enabled property was set to false. I set it to true and now the scrollbars work properly. I just assumed that it was enabled by default. I thought that was true for all controls but you have changed my mind!
Thank you!
|
|
|
|
|
robwm1 wrote: I just assumed that it was enabled by default It is
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I must have changed it at some point. This is my first C# project and I have done a lot of experimentation. Just need to remember to undo any changes I make that don't give the results I am looking for so everything remains in its default state.
I am my own job security...
|
|
|
|
|
Are you using a code-repository like SourceSafe where you can easily undo all changes?
I usually copy the complete project to a RAM-disk for experiments
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
My code is stored within Team Foundation Server so I could roll back if needed. That's a great idea with the ram drive although using disk storage, if you have the space available, might work as well. Either way, I have been making changes as I progress to learn the language and IDE better without making copies. Probably not the best idea but I don't plan to code this way in the long term.
|
|
|
|
|
I have a problem with my script:
Public partial class Form_Process : Form
{
Static Object[ , , ] normW = null;
Private void process(){
for(int i=0; i<3; i++){
normalW[i] = Normali;
}
}
}
Error: Wrong number of indices inside []; expected 3
I hope anyone can help me for my error script above.
I'm sorry for my bad english. Thank you.
modified 9-Jan-15 16:46pm.
|
|
|
|
|
There are a number of problems, including that you never instantiate the array.
First off, why an array? Rather than a Tuple or a List?
Are you actually trying to make an array of three two-dimensional arrays?
Try
Object[,][] normalW = new Object[,][ 3 ] ;
(Untested)
(That ain't working.)
|
|
|
|
|
Yes, i wanna try to use 3 dimensional array, just for learning.
I also used a List. Thank's a lot.
|
|
|
|
|
Is normW the same as normalW? If yes, then you declared it as a 3 dimensional variable.
If you solve it, you'll get the same error on Normali if that is indeed a 2 dimensional variable.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes i'm sorry. Thank you. NormW is same as NormalW. I try to save the Normali[i, j] (2 dimensional) in NormW[z, i, j] (3 dimensional)
|
|
|
|
|
Sample 3-dimensional Array initialization:
int[,,] d3ary = new int[3, 4, 5];
for (int i = 0; i < d3ary.GetUpperBound(0); i++)
{
for (int j = 0; j < d3ary.GetUpperBound(1); j++)
{
for (int k = 0; k < d3ary.GetUpperBound(2); k++)
{
d3ary[i, j, k] =
}
}
}
«A man will be imprisoned in a room with a door that's unlocked and opens inwards ... as long as it does not occur to him to pull rather than push» Wittgenstein
|
|
|
|
|
Yes, you're right. I used the code like yours. But i used d3ary.GetLength(0). Is that same with d3ary.GetUpperBound(0)?
|
|
|
|
|
In C#, for all practical purposes, it is legitimate to consider the value returned by 'GetUpperBound to be the same as the value returned by GetLength. Normally in C#: Array.GetLowerBound(#n) will return zero.
It is possible, though unusual, to have Arrays in C# whose lower bounds are not zero; for example: you might inter-operate with Excel and get an Array whose indexes are one-based. Or you can create such strange arrays by using the Array.CreateInstance(Type, Int32[], Int32[]) overload of Array.CreateInstance.
Here's a one-based array of string of length #5:
Array oneBasedArray = Array.CreateInstance(typeof(string), new int[] { 5 }, new int[] { 1 });
oneBasedArray.SetValue("hello", 1); And:
> ? oneBasedArray.GetUpperBound(0)
5
> ? oneBasedArray.GetLength(0)
5
> ? oneBasedArray.GetLowerBound(0)
1 I suggest you engage with non-zero based Arrays as you need to in the course of inter-op with COM, or whatever.
«A man will be imprisoned in a room with a door that's unlocked and opens inwards ... as long as it does not occur to him to pull rather than push» Wittgenstein
|
|
|
|
|
Ok, I got the point. So, GetUpperBound and GetLowerBound are more flexible than using GetLength, aren't they?
They're used as we need.
Thank you BillWoodruff.
|
|
|
|
|
If you're going to use GetUpperBound , then your loop condition needs to be <= rather than < .
GetUpperBound returns the last index for the dimension, not the length.
int[,,] d3ary = new int[3, 4, 5];
Console.WriteLine("{0}, {1}, {2}", d3ary.GetUpperBound(0), d3ary.GetUpperBound(1), d3ary.GetUpperBound(2));
Console.WriteLine("{0}, {1}, {2}", d3ary.GetLength(0), d3ary.GetLength(1), d3ary.GetLength(2));
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
When you declare a three dimensional array, you are saying that each row, column and zaxis-whatever-it-is-called is the same size:
object[,,] ar3d = new object[2,3,4]; But that isn't necessarily the case with the code you show - we have no guarantee that each of the 2D arrays loaded into Normali is the same each time. And if we aren't sure, nor is the compiler!
So when you try to assign a new 2D array to a row, it complains because a 3D array is not made up of arrays of references to arrays of references to objects - it is in fact a flat linear space of objects which is interpreted as a 3D array.
Probably, what you are trying to do is construct a jagged array:
object[][,] normW = new object[3][,];
for (int i = 0; i < normW.Length; i++)
{
object[,] normali = MyProcess(i);
normW[i] = normali;
} Where it doesn't matter what the dimensions of the array you generate in your processing are.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Ok, Thank you for your help. I got it.
|
|
|
|
|
Ah, so I had them backward? That's counter-intuitive.
|
|
|
|
|
Hi,
Why I am getting Object reference not set to an instance of an object when trying to read from registry? although I have a valid value there! The error is shown on this line:
connection_string = "Server=" + myapplication.GetValue("ServerHost").ToString() + ";";
and the value of ServerHost is 127.0.0.1
public string get_connectionstring(string system_key)
{
string connection_string;
RegistryKey myapplication_registry = Registry.LocalMachine.OpenSubKey("SOFTWARE\\myapplication", true);
RegistryKey system_registry = Registry.LocalMachine.OpenSubKey("SOFTWARE\\myapplication\\" + system_key, true);
connection_string = "Server=" + myapplication.GetValue("ServerHost").ToString() + ";";
connection_string += "Port=" + myapplication.GetValue("ServerPort").ToString() + ";";
connection_string += "Database=" + system_registry.GetValue("DatabaseName").ToString() + ";";
connection_string += "Uid=" + myapplication.GetValue("ServerUserID").ToString() + ";";
connection_string += "Pwd=" + cipher_utility.Decrypt<RijndaelManaged>(myapplication.GetValue("ServerPassword").ToString(), "{xxxxx-xxxx-xxxx-xxxx-xxxxxx}", "{xxxx-xxxx-xxxx-xxxx-xxxxx}") + ";";
connection_string += "Connect Timeout=" + myapplication.GetValue("ConnectTimeout").ToString()+ ";";
connection_string += "default command timeout=" + myapplication.GetValue("ConnectTimeout").ToString() + ";";
return connection_string;
}
Technology News @ www.JassimRahma.com
|
|
|
|
|
Thanks guys,
I found the problem.
It was an issue with processor type.
The PC was 64bit and the exe was 32bit.
http://www.softnames.com
|
|
|
|