|
|
Hi,
First of all, Please let me know if I am posting in the wrong forum.
I am tryingto access a class written in c# which has an array of classes. The class code is:
public class ClientData
{
private ClientDataDetail benchmark;
private ClientData[] buckets;
private ClientDataDetail portfolio;
public ClientDataDetail BenchMark
{
get{ return benchmark;}
set{ benchmark = value;}
}
public ClientData[] Buckets
{
get{ return buckets;}
set{ buckets = value;}
}
public ClientDataDetail Portfolio
{
get{ return portfolio;}
set{ portfolio = value;}
}
}
When I try to access this class in VBA as follows:
Dim clntData As ClientData
Set clntData = dispData.GetClientData()
//This is the line where I get the error: "Wrong Number of arguments or Invalid property assignment"
Dim anotherClntData As ClientData
<b> anotherClntData = clntData.Buckets(0)</b>
The same code (i.e. accessing the internal array of ClientData class via the indexer) works perfectly fine in c#.
Any pointers. Do I need to use an arraylist in place of array of classes?
|
|
|
|
|
newbieNeeraj wrote: anotherClntData = clntData.Buckets(0)
Your C# Buckets function gets or sets the whole buckets array (gets or sets ClientData[]) but you want to get one element from Buckets (ClientData)
|
|
|
|
|
Hi Pedram, Thanks for replying.
I do undertsand your reply.But then Please let me understand how come the same code functions correctly in c#? (If I understand what makes it work in C# maybe I could implement the same thing in VBA) Code sample below:
DisplayData cd = new DisplayData();
ClientData clntdata = new ClientData();
clntdata = cd.GetClientData();
ClientData data1 = new ClientData();
data1 = clntdata.Buckets[0];
Thanks,
Neeraj
|
|
|
|
|
I think this works:
DisplayData cd = new DisplayData();
ClientData clntdata = new ClientData();
clntdata = cd.GetClientData();
ClientData data1 = new ClientData();
cd.Buckets = new ClientData[100];
data1 = clntdata.Buckets[0];
modified on Saturday, September 27, 2008 3:50 AM
|
|
|
|
|
Hi Pedram,
Sorry for the late reply. Had left office the other day and I didn't have net access at home.
You are right. I am setting clientData.Buckets to some meaningful value. That was inside the function GetClientData().
What I am asking is that even after doing this,
ClientData data1 = new ClientData();
cd.Buckets = new ClientData[100];
// clndata.Buckets[0] = //Something usefull
data1 = clntdata.Buckets[0];
The last line gives me error. But the other two classes i. e. Protfolio and BEnchmark are accessible in VBA.
If I have an array of classes (private ClientData[] buckets;) in the class (ClientData) itself, can we not access it like c#? If not how can we modify the code to access it?
Thanks again for your time.
|
|
|
|
|
Hello newbieNeeraj
newbieNeeraj wrote: Sorry for the late reply.
I saw your post right now so I'm sorry too.
newbieNeeraj wrote: What I am asking is that even after doing this,
ClientData data1 = new ClientData();
cd.Buckets = new ClientData[100];
// clndata.Buckets[0] = //Something usefull
data1 = clntdata.Buckets[0];
The last line gives me error.
Did you uncomment line 3?
If not, it's like this:
int a;
int b = a;
Did you understand? You have to set a value for your variable before you can get it.
If yes and you uncomment line 3, I really don't know what is happening to your application, and unfortunately I have no more idea
What's your error message?
While (true) { Human.isLearnable = true; }
|
|
|
|
|
I want to set two find options : "MachCase" and "WholeWord"
this code works correctly :
richTextBox1.Find(StrSearch, RichTextBoxFinds.MatchCase);
but this code doesn`t work; It has compiler Error :
richTextBox1.Find(StrSearch, RichTextBoxFinds.MatchCase, RichTextBoxFinds.WholeWord);
How should I write this code to set either RichTextBoxFinds.MatchCase, RichTextBoxFinds.WholeWord
Hello Friends
|
|
|
|
|
Laji59 wrote: richTextBox1.Find(StrSearch, RichTextBoxFinds.MatchCase, RichTextBoxFinds.WholeWord);
If you noticed, RichTextBox.Find method has two arguments: string str, RichTextBoxFinds option.
So you have error.
You should ask your user which option he/she wants. MatchCase OR WholeWord
|
|
|
|
|
I know. But May be an User have either "MachCase" and "WholeWord" even more like "search Foreward or Backward".
This ability is also in Standard application like Microsoft Word or Visual Studio
Hello Friends
|
|
|
|
|
Well simply search your text with MatchCase if Find can't find anything (returns -1) search for WholeWord.
|
|
|
|
|
can any one tell me the references regarding Slide-In Menu Bar
which can be created or implemented in windows application using c#??
thanks in advance............
|
|
|
|
|
|
No,
i want slidding window for my application which can be running while do another work on my pc,
i.e. like windows background services
when i want to look my current usage or that application when i move cursor on it,
slide bar from left/right/top/bottom
thanks for reply
|
|
|
|
|
If I could understand you, you should try creating a child form for a MDIParent and with child form's MouseMove event you can done it.
|
|
|
|
|
|
hi
i want to backup from my database i used following code but it do not work properly
and it rises an exception
(my database name is 'Alarms' )
Backup backup = new Backup();
backup.Action = BackupActionType.Database;
backup.BackupSetName = "Archive_NeaxExpander";
backup.Database = "Alarms";
backup.PercentCompleteNotification = 10;
BackupDeviceItem device = new BackupDeviceItem(path, DeviceType.File);
ServerConnection connection = new ServerConnection(new SqlConnection(ConnectionString));
Server server = new Server(connection);
Database DB = server.Databases["Alarms"];
backup.Initialize = true;
backup.Checksum = true;
backup.ContinueAfterError = true;
backup.Devices.Add(device);
backup.Incremental = false;
backup.FormatMedia = false;
backup.SqlBackup(server);
i recive following exception
Microsoft.SqlServer.Management.Smo.FailedOperationException was unhandled by user code HelpLink="http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Backup+Server&LinkId=20476"
Message="Backup failed for Server 'MRTSOFT-F5CFDAC'. "
Source="Microsoft.SqlServer.Smo"
Operation="Backup"
i used my current connectionstring as an addmin
to add , insert , select ,... and it works properly
and i sore that i have backup premission with this connectionstring
i used the following code to resive servers list
DataTable dtServers = SmoApplication.EnumAvailableSqlServers(false);
//or
DataTable dtServers = SmoApplication.EnumAvailableSqlServers(true);
but it`s dtServers.rows.count is zero and perhaps it means no server is available
so what can i do
i really confused by SQL
|
|
|
|
|
realize the truth
----------------------------------
Be excellent to each other
|
|
|
|
|
I need to implement vfp function which uses * and ? wildcards:
static bool Like( cExpression1, cExpression2)
cExpression1
Specifies the character expression that Like( ) compares with cExpression2.
cExpression1 can contain the wildcards such as * and ?. The question mark
(?) matches any single character in cExpression2 and the asterisk (*)
matches any number of characters. You can mix any number of wildcards in any
combination in cExpression1.
cExpression2
Specifies the character expression LIKE( ) compares with cExpression1.
returns true on wildcards match.
How to implement this ?
Andrus
|
|
|
|
|
You should look up Regex (Regular Expressions), it should do everything you need (and oh so much more)
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
You should look at using regular expressions. Do a search on this site for Expresso, it is a really cool tool for building regular expressions.
"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
|
|
|
|
|
|
Is there a way to use the .NET cryptography library to encrypt binary files as opposed to plain text files? I've been having a few issues with the way that encrypted bytes are decrypted back to their original state.
What I do to initialize my algorithm for decryption is approximately the following:
UnicodeEncoding byteConverter = new UnicodeEncoding();
RijndaelManaged algorithm = new RijndaelManaged();
algorithm.IV = byteConverter->GetBytes();
algorithm.Key = byteConverter->GetBytes();
return alg;
In order to encrypt, first, I call that stub of algorithm initialization code. Then I do approximately the following with a Byte[] data that I want to encrypt:
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, algorithm.CreateEncryptor(), CryptoStreamMode.Write);
for (int i = 0; i < numBytes; i++)
{
cs.WriteByte(data[i]);
}
cs.FlushFinalBlock();
byte encoded[] = ms.ToArray();
cs.Close();
ms.Close();
string output = Convert.ToBase64String(encoded);
In order to decrypt, first, I call that stub of algorithm initialization code. Then I do approximately the following with a string input that I want to decrypt:
byte[] encoded = Convert.FromBase64String(input);
MemoryStream ms = new MemoryStream(encoded);
CryptoStream cs = new CryptoStream(ms, algorithm.CreateDecryptor(), CryptoStreamMode.Read);
byte decoded[] = new byte[encoded.Length];
for (int i = 0; i < decoded.Length; i++)
{
int readByte = cs.ReadByte();
if (readByte != -1)
{
decoded[i] = (byte)readByte;
}
}
cs.Close();
ms.Close();
The problem is that if I call Encrypt , then Decrypt , encryption leaves me with a nice base64 string, which decrypt easily converts back to a byte array. But when I read the CryptoStream and get check all the values of int readByte everytime I read a byte, as soon as I come to the null-terminated character (0 '' ), everything else that I read after that is the same garbage symbol (-51 'Í' ). More precisely, the code that I'm writing here is the C# equivalent of my Managed C++ code (however, the problem does not lie in the unmanaged part or the unmanaged/managed conversion). So, to rephrase what I mean, say that I'm checking all the values of readByte for i = 0 to the length of the decoded byte array (which hasn't yet been filled), if ReadByte happens to return me 66, 77, 54, 44, 23, 0, respectively, everything else after that is -51. If I'm decrypting binary data, I will run into this issue. If I'm decrypting text data, then I won't, since in a text string, 0 is the null-terminated character that only occurs at the very end of the string (and I've got all my bytes at that point anyway).
Any suggestions? Thanks, and I apologize for the long post.
|
|
|
|
|
Skip the base 64 string part. Since you are using a binary file you should be using a FileStream or some other stream. I have never had any trouble encrypting streams.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Well, base64 is easily encoded in a string, or a MemoryStream (which is what I'm using). What I'm essentially doing afterwards when I write to a file is actually saving the base64 encoded string directly to the file like I save text. Thanks for the FileStream suggestion... maybe that's also a plausible implementation.
Also, I've toyed around with the idea of doing multiple base64 conversions, so converting a binary file to base64 first, then encrypting, then encoding to base64 again. After every base64 transform step, I'm able to again fit the entire "data" of the file into an ANSI string.
|
|
|
|