|
cheers guys that worked great
i've only decided this week to make a move over from vb6 / vb.net to c# so it's all new , although i'm beginning to grasp the concepts a bit now.
thanks a lot.
|
|
|
|
|
using System;
namespace testString
{
class testString
{
public static void Main(string[] args)
{
string secondword = "";
string text = "hello i'm a test";
string[] fragments = text.Split(new char[] {' '});
if( fragments.Length > 2 )
{
secondword = fragments[1];
}
Console.WriteLine(text + "\n" + secondword);
}
}
}
This will return i'm.
|
|
|
|
|
You can use the code sample I posted above just to test and see it write out the second word to the command line. Alternatively, here is a method you can add to your class or a utility class to just get the second word. This will return the 2nd word, or a zero-length string if there is no 2nd word. Yes I was bored Time to sleep now.
private string GetSecondWord(string TextIn)
{
string secondword = "";
string[] fragments = TextIn.Split(new char[] {' '});
if( fragments.Length > 2 )
{
secondword = fragments[1];
}
return secondword;
} Happy To Help,
Joe Mozelesky
imoz technologies, llc :: powered by imoz
|
|
|
|
|
I would like to know the procedure for Printing WinForm Controls, both Built-in and Custom Controls.
BETTER TO BURN OUT THAN TO FADE AWAY - Anonymous
|
|
|
|
|
Hi,
I am still amazed that nulls or blanks can not be entered in the DateTimePicker control. Everybody in my employee database needs to be terminated because of this (sarcastic).
I had to resort to either defaulting all dates with 1/1/1900 and then saving it as null in my Stored Procedures, or use a textbox with a custom coded 'format' capability for dates.
Does anyone know of a better way of doing this, that can be deployed in a marketed application. (not an in-house project where you can get away with iffy controls).
I am held up to go to production because of this and the textbox class not having an InputMask.
Thanks,
Chris
|
|
|
|
|
http://www.syncfusion.com/forums/message.asp?MessageID=1464
Here, sample code which exactly does what u want
-S
|
|
|
|
|
The web service works, but the methods are not available from a remote machine. Instead I get this "The testservice form is only available for requests from the local machine.". I've done this before, just messing around and it all went perfectly. Now that I'm under a deadline and actually working on a project I've run into this little nusance; any help anyone?
Fear not my insanity, fear the mind it protects.
|
|
|
|
|
Hi,
I have been battleing with the fact that there is no InputMask or Format property on the TextBox control in Windows Forms.
I have spent the last 8 months designing my classes, but I am still stuck on this.
How can I get the same Format capabilities of the DataGridColumn in a standard textbox.
I have played with the two examples that come up on Google, but they fall way short of a production capable control. I worked for the last two weeks to get this to work.
The example on C# Help is incomplete and does not have a link to the code.
Does anyone have or know of where I can get the code to format my textboxes?
I can not tell my customers that this functionality is not available.
In VFP, you just typed in $$$99.99 or !!!!!!! for example. I am trying to duplicate this or the DataGridColumn.Format.
Thanks,
Chris
|
|
|
|
|
Do a little searching, you will find a masked edit box at code project itself, shows you how to implement a Masked box for decimals, ints. social security, ips . etc ..
-S
|
|
|
|
|
Hi Sameer,
I actually had Michael send me his code from the example posted on C# help. It used regular expressions.
I am working on it for my use and it is going well.
I tried the other example, but it did not work well in the field.
Thanks,
Chris
|
|
|
|
|
Hey again,
I'm animating an image across the screen. My problem is, it seems to studder as it moves across the screen. This gets more pronounced the faster I move the image. Is there any way to get nice smooth animation?
I'm using the DirectX animation example as my guide but it doesn't seem to be fixing the problem. Should I create a separate thread for setting the frame rate? That's really what I'm looking for. Some way to syncronize the framerate.
Thanks,
EvilDingo
|
|
|
|
|
have you tried looking into double buffering? or maybe vsynch? i havent done any work with directx, but those two things are prolly what you'll need..
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
I have a database connection in one assembly, and I have a Crystal report in another Windows forms Application.
I want my Crystal report to access Database through the connection in first assembly.
Is this possible? Idea is to keep a single database connection.
Please Help !!!!!
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
Still not up on assemblies and the other nicities of C# yet. If you can put up with C++ jargon though, it should work like this:
Instantiate the assembly. Pass the connection instance to the form app using the C# ref keyword, and store it with a member variable. It is my understanding, though I haven't tested it yet, that the member variable will persist as a reference (pointer?) to the original connection.
>>>-----> MikeO
|
|
|
|
|
hi,
i wuold like to draw charts in my application and after copy and paste charts under Excel or Word ...
is OLE a good way to search method to do my job ?
thx
|
|
|
|
|
Hi there,
I’m using a Win32 API dll, Winscard.dll, for which there is no current equivalent in the .NET Framework.
Several of the functions require the use of ByRef arrays, e.g. pointers, when calling the api function. From following the examples in MSDN, I am able to set up the pointers needed for the array, but am having difficulty setting the correct size of the pointer using AllocCoTaskMem.
The function I’m trying to call in Winscard.dll is SCardStatus. From the documentation, this is declared as:
LONG SCardStatus(
SCARDHANDLE hCard,
LPTSTR szReaderName,
LPDWORD pcchReaderLen,
LPDWORD pdwState,
LPDWORD pdwProtocol,
LPBYTE pbAtr,
LPDWORD pcbAtrLen
);
My function declaration in C# is thus:
[DllImport("winscard.dll")]
static unsafe extern int SCardStatus (IntPtr hContext, out StringBuilder szReaderName , ref IntPtr pcchReaderLen, out IntPtr pdwState, out IntPtr pdwProtocol, ref IntPtr pbAtr, ref int pcbAtrLen);
This uses an IntPtr “pbAtr” to receive the array.
I declare an array (emptyATRArray) to act as the original array:
private byte[] emptyATRArray = new byte[32];
And create another variable, “size”, based upon the size of this
int size = emptyATRArray.Length;
Using the template in MSDN as an example, I then create a pointer called “buffer” to pass to the function:
IntPtr buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(size) * emptyATRArray.Length);
I then call the function:
lngResult = cSmartCard.SCardStatus(lngCard, out strGetReader,ref intReaderNameLen,out intReaderState, out intReaderProtocol, ref buffer, ref retATRLen);
I am happy that the function has worked correctly, as the value of the pcbAtrLen variable, (retATRLen) has correctly changed from 0 (in this case to 13, the expected number of bytes for the particular smartcard), as well as the other ByRef integers.
To extract the values of the updated array, I create a new byte array called returnedATRArray of the size retuned to retATRLen (13), and copy all the values from the buffer to the this new array:
Marshal.Copy(buffer, returnedATRArray,0,retATRLen);
And free the memory:
Marshal.FreeCoTaskMem(buffer);
This then gives me a correctly sized array, which I can cycle through to extract the values:
strATR= new StringBuilder();
foreach (byte atrByte in returnedATRArray) {
strATR.Append (Convert.ToString(atrByte,16) + ' ');
}
Console.Write("ATR: " + strATR.ToString());
However, from cross-checking with another program, I know that the values returned to returnedATRArray are not correct. By fiddling with the parameters to AllocCoTaskMem, I can get different values out of the final array, so I assume that the amount of memory allocated here is crucial.
I’ve been unable to find a clear guide as to how to define the size of the block of memory for such operations. Could anyone help
Cheers
Toby
|
|
|
|
|
I need to do serial comms in C#; that is, I need to be able to open COMn and read/write it.
I would also like to be able to set the comm parameters (SetCommDCB and SetCommTimeouts) but this is not essential.
How can I do this?
(I'm fully familiar with doing the same kind of stuff in C++).
tia
Phil
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
|
Thanks!
That's enough to get me started ... I'm off and coding.
Phil
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
I have the following config file:
<configuration>
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener,System" initializeData="c:\myListener.log" />
<remove type="System.Diagnostics.DefaultTraceListener,System"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>
Running this and using the Trace class brings up the following exception:
An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.dll
Additional information: Couldn't find type for class System.Diagnostics.TextWriterTraceListener,System.
I certainly have a reference to the System assembly.
|
|
|
|
|
Two things:
First, the sample in MSDN doesn't put ,System at the end of the TextWriterTraceListener definition. Oddly the text on obtaining the full name of assemblies does include that as well as the version, culture, and public key token so try both ways.
Second, you need to specify the fully qualified name for the item you are removing. You only specified the class name and assembly, you also need to specify version, culture, and public key token.
For example:
"System.Diagnostics.TextWriterTraceListener, System, version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
If you are targetting .NET v1.1 change the version part to 1.0.5000.0
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
Tx James I'll try that. But...
James T. Johnson wrote:
First, the sample in MSDN doesn't put ,System
In the version I have it does. But the same example at the MSDN library online is different. I'll look into that.
|
|
|
|
|
hi!
i get problem when set 'DisplayMember' and 'ValueMember' for combo box (get data from oracle database, using OleDb).
comboBox.DataSource=DataSet.Tables[0];
comboBox.DisplayMember="DisplayMember";
comboBox.ValueMember="ValueMember";
the same code is OK when I connect to access or sql, but get bug when connect to oracle database.
help me
thanks.
|
|
|
|
|
|
.NET Framework must be 1.1, I could connect to oracle with OleDb for other action like execute sql command, get data reader,...
but got above problem with combo box.
|
|
|
|
|