|
You can cast a character to an int to get the character code:
char foo = 'A';<br />
int bar = (int)foo;
After changing the character code you can cast the int to char.
---
b { font-weight: normal; }
|
|
|
|
|
Good job doing his homework for him. Hopefully in a few years you can reap your reward by having to work with him.
led mike
|
|
|
|
|
If the homework was to convert a character to an integer, yes, then I have done his homework. I doubt, however, that his homework is quite as simple as that.
Hopefully in a few years he has moved beyond basic data conversion, and will be able to actually do something with the data.
---
b { font-weight: normal; }
|
|
|
|
|
Finally Got it.....Thanks for all the Help Guffa, I was making it harder than it was, but once I got the foreach loop and char 'A' to int the program almost finished itself.
Here's the completed code snippet
private void btnEn_Click(object sender, EventArgs e)
{
string result = "";
foreach (char abc in txtUn.Text)
{
result = result + Convert.ToChar(Convert.ToInt16(abc) + 3);
}
txtEn.Text = result;
}
public void btnDe_Click(object sender, EventArgs e)
{
string result = "";
foreach (char abc in txtUn.Text)
{
result = result + Convert.ToChar(Convert.ToInt16(abc) - 3);
}
txtDe.Text = result;
}
|
|
|
|
|
Works beatifully thanks for the quick help. But I'm now trying to convert multiple characters in one text box.
Such as....
ABC +3 =DEF
I've tried string and looping things, but can't seem to manipulate it correctly.
|
|
|
|
|
Remember that strings are immutable, so you can't change a string.
You can use an array of characters, each character in the array can be manipulated. You can turn a string into an array of characters, and back to a string.
---
b { font-weight: normal; }
|
|
|
|
|
Bobbydoo9 wrote: but I'm having very little luck
Luck has nothing to do with it.
Bobbydoo9 wrote: I can never find the right code snippets
You should consider "writing" your own code rather than using "copy-paste" to develop software.
Bobbydoo9 wrote: What i'm trying to do is take "A"
and add 3 (+3)
and come up with "D" "D"
It's a secret so don't tell on my for this but.... information about how to do that has been skillfully hidden in the C# documentation by Microsoft.
have fun with your homework assignment.
led mike
|
|
|
|
|
led mike wrote: You should consider "writing" your own code rather than using "copy-paste" to develop software.
It would be awesome if someone wrote an usable program ENTIRELY out of little snippets found on teh Interwebs, with references and everything...
Windows Calculator told me I will die at 28.
|
|
|
|
|
I hope this helps
int a = Convert.ToInt16('A');
a = a+3;
Console.WriteLine(Convert.ToChar(a));
|
|
|
|
|
Hi,
Is there a way to programatically scroll to the bottom of a listview (it's in detail mode)?
thanx
|
|
|
|
|
|
Thanx!
I was looking for something like "ScrollTo" and didn't find it..
|
|
|
|
|
I have a datagrid that is using table styles. I want to allow users to select which columns are visible through a basic column selction form.
The problem I am having is that whatever cell is currently selected when I launch my columnselction form stays selected and will never lose focus! I can select other cells afterwards but the original cell always stays selected. If I launch the columnselection form additional times, whatever cell has focus then also stays focused. Hence, I can have 25 cells with permanent focus if I launched my columnselection form 25 times.
My code is as follows:
//Mainform code to get current visible columns and to launch columnselection form
ArrayList columns = new ArrayList();
for(int i=0; i<this.cdatagrid.tablestyles[0].gridcolumnstyles.count; i++)
{
string="" temp="this.cDataGrid.TableStyles[0].GridColumnStyles[i].MappingName;
columns.Add(temp);
}
vc" =="" new="" viewablecolumnsfordg(this,="" columns);
this.enabled="false;
vc.Show();
//Code" in="" vc="" after="" selecting="" columns
private="" void="" selectbutton_click(object="" sender,="" system.eventargs="" e)
{
="" mainform.cdatagrid.suspendlayout();
="" this.columns.clear();
="" for(int="" i="0;" <="" cboxlist.count;="" i++)
="" {
="" checkbox="" cb="(CheckBox)cBoxList[i];
" if(cb.checked)
="" columns.add(cb.text);
="" }
="" mainform.viewablecolumns="this.columns;
" mainform.cdatagrid.tablestyles.clear();
="" mainform.setctablestlye();
="" mainform.enabled="true;
" mainform.bringtofront();
="" mainform.cdatagrid.refresh();
="" mainform.cdatagrid.update();
="" mainform.cdatagrid.resumelayout();
="" this.close();
}
="" mainform="" code="" for="" setctablestlye();
public="" setctablestlye()
{
="" datagridtablestyle="" tblstyle="new" datagridtablestyle();
="" tblstyle.mappingname="mainData" ;
="" viewablecolumns.count;="" j="0;" standardcolnames.count;="" j++)
="" datagridtextboxcolumn="" dgcol="createDataGridColumn((string)viewableColumns[i]);
" tblstyle.gridcolumnstyles.add(dgcol);
="" tblstyle.rowheadersvisible="false;
" }
="" cdatagrid.tablestyles.add(tblstyle);
}
="" createdatagridcolumn
private="" createdatagridcolumn(string="" mappingname)
{
="" datagridtextboxcolumn();
="" dgcol.mappingname="mappingName;
" dgcol.headertext="mappingName;"
="" dgcol.width="115;
" dgcol.nulltext="String.Empty;
" dgcol.textbox.click="" +="new" system.eventhandler(openc_clicked);
="" dgcol.textbox.keydown="" system.windows.forms.keyeventhandler(openc_enterkey);
="" dgcol.readonly="true;
" return="" dgcol;
}
i'm="" sure="" this="" is="" really="" simple="" but="" can't="" find="" a="" way="" to="" unfocus="" the="" column=""
thanks!=""
<div="" class="ForumSig">RABB17
"Nothing fancy needed, please just solve all our problems as quickly as possible."
|
|
|
|
|
I'm using global keyboard and mouse hooks in an app. Under XP it runs fine, under 2k or NT4 it does as well, except for one really wierd behavior. If I do a crtl-alt-del while the hooks are set, and close the screen with the escape key instead of the mouse once I exit my app double clicking in explorer or on the desktop no longer work, not does selecting an icon and hitting enter. This doesn't happen in XP, it doesn't happen in 2k if I close the screen using the mouse.
Since this doesn't happen under XP I strongly suspect it's a windows issue that was fixed but not backpatched to older versions. That said, has anyone seen this before, or have any idea how to fix/work around the issue?
|
|
|
|
|
Hello,
I have an PowerPoint2003 Add-In developed in C#.
It is possible to port it on Mac? (MS PowerPoint 2004 for Mac)
If no - what kind of alternatives would you recommend?
Thanks
|
|
|
|
|
I'm not sure if Mono supports MAC, but I would check there first.
|
|
|
|
|
I have a screen that is populated by moving up and down a list view.
If I move through the list quickly (indexchange event) the population of the form goes crazy and I lose focus on the list box. I suspect that it is validation that is causing the problem as the form is populated and focus moves from the various controls.
How can I suspend these events untill after the form is populated?
|
|
|
|
|
why this code doesn`t work? (VS 2003)
declaration, and, possibly, assigment:
DateTime dataTermino = null;<br />
if(txtDataInicio.Text != "")<br />
dataTermino = DateTime.Parse(txtDataTermino.Text);
and, in another class, the test:
if(dataTermino != null)<br />
insertCommand.Parameters.Add(new SqlParameter("@DataTermino", dataTermino));
VS2003 Errors:
* Operator '!=' cannot be applied to operands of type 'System.DateTime' and 'null'
* Cannot convert null to 'System.DateTime' because it is a value type
WTF!
thanks...
|
|
|
|
|
before using the datetime variable you must create it.
DateTime dataTermino = new DateTime()
will do the job for you
|
|
|
|
|
ok, but after i want test if it is null.
with a object reference i cant test it, and i dont want reference the actual date.
|
|
|
|
|
There are 2 types of objects in .NET: reference types and value types. All classes are reference types. All structs are value types. All reference types can be assigned null. All value types cannot.
The reason for these 2 is for lightweight, fast stack-allocated values. For instance, System.Int32 , also aliased as int is a value type: you can pass it to a function which will actually pass a copy of the value.
Value types always must have a value; you can't assign them null, as that's not how value types work, nor should it be. Assigning an integer to null doesn't make sense, for instance. And since DateTime is a value type, you can't assign null to it.
Now, if you were using .NET 2.0, there is a new wrapper class called System.Nullable, where you can wrap a value type inside an object that can either be null or the value. Here's what that looks like:
Nullable<DateTime> nullableDateTime = new Nullable<DateTime>;
nullableDateTime = null;
nullableDateTime = DateTime.Now;
C# 2.0 has short-hand syntax for this, using the question mark:
DateTime? nullableDateTime = new DateTime?();
nullableDateTime = null;
nullableDateTime = DateTime.Now;
|
|
|
|
|
hey... thanks...
i`ve used a overloaded method to deal with this situation, instead of testing if a parameter is null or not.
great explanation... it was very instructive. :]
cya
|
|
|
|
|
tcss wrote: before using the datetime variable you must create it.
Not at all. DateTime is a value type, not a reference type.
---
b { font-weight: normal; }
|
|
|
|
|
Cut my teeth in C# with .Net 2.0. See comment below.
Thanks for correcting my post
|
|
|
|
|
The DateTime class is a struct and so can't be null. It's just like int, double, or one of the other value types, they can't be null.
|
|
|
|