Register for your free account! | Forgot your password?

You last visited: Today at 09:06

  • Please register to post and access all features, it's quick, easy and FREE!


[C#]Basic Problem

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2007
Posts: 145
Received Thanks: 8
[C#]Basic Problem



How to make this?

Character string entered from textbox within the framework of defined rules change below to display a label. Each odd-numbered characters in the string of characters from the character after the change in him. These rules next couple bi the file.

Example: ABCDEFGHIJK -> CBAFEDİHGJK



xxFastBoy is offline  
Old 11/22/2009, 00:50   #2
 
elite*gold: 0
Join Date: Mar 2006
Posts: 98
Received Thanks: 9
Quote:
Originally Posted by xxFastBoy View Post


How to make this?

Character string entered from textbox within the framework of defined rules change below to display a label. Each odd-numbered characters in the string of characters from the character after the change in him. These rules next couple bi the file.

Example: ABCDEFGHIJK -> CBAFEDİHGJK
I'm not familiair with C# and visual studio but if I understand it correctly, you want a string to change from a certain value to a value which is given as input by the user?

This is how I would do it in java:
So for example:

String myString = "ABCD";
Scanner myScan = new Scanner(System.in);
myString = myScan.nextLine();


Diabox is offline  
Thanks
1 User
Old 11/22/2009, 01:25   #3
 
elite*gold: 0
Join Date: Nov 2009
Posts: 149
Received Thanks: 22
Is it set to random, cause is same letters?
#*=DarkAngeL=*# is offline  
Thanks
1 User
Old 11/22/2009, 01:41   #4
 
elite*gold: 0
Join Date: Jun 2007
Posts: 145
Received Thanks: 8
Quote:
Originally Posted by #*=DarkAngeL=*# View Post
Is it set to random, cause is same letters?
No its Not Randomly

Example

ABCDEFGHIJK -> CBAFEDIHGJK

ABC = CBA - DEF = FED - GHI = IHG - JK = JK


its my homework from School But I Dont Know how To make our teacher Verry Stupid. :S


xxFastBoy is offline  
Old 11/22/2009, 01:48   #5
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,124
Received Thanks: 2,500
Code:
for (int i = 0; i < textBox1.Length; i++)
{
     if(i & 1) //Odd Number
     {
          label1.Text[i] = textBox1.Text[i + 2];
     }
     else //Even Number
     {
          label1.Text[i] = textBox1.Text[i];
     }
}
Something similar to that, ive not tested it, but i think that should do something similar to what you want.
Korvacs is offline  
Thanks
1 User
Old 11/22/2009, 03:14   #6
 
elite*gold: 0
Join Date: Jun 2007
Posts: 145
Received Thanks: 8
Quote:
Originally Posted by Korvacs View Post
Code:
for (int i = 0; i < textBox1.Length; i++)
{
     if(i & 1) //Odd Number
     {
          label1.Text[i] = textBox1.Text[i + 2];
     }
     else //Even Number
     {
          label1.Text[i] = textBox1.Text[i];
     }
}
Something similar to that, ive not tested it, but i think that should do something similar to what you want.

thanks but i got some errors

in here
Quote:
for (int i = 0; i < textBox1.Length; i++)

"system.windows.forms.textbox. does not contain a definitiation for 'lenght' and no extension method 'lenght' accepting a firs arrgument of type 'system.windows.forms.textbox' could be found (are you missing a using directive or an assembly reference?)"
And

in here
Quote:
if (i & 1)

" cannot implicitly convert type 'int' to 'bool' "
in here
Quote:
label1.Text[i]


Property or indexer 'string.tis[int]' cannot be assigned to -- it is read only
xxFastBoy is offline  
Old 11/22/2009, 10:50   #7
 
elite*gold: 0
Join Date: Feb 2006
Posts: 550
Received Thanks: 79
do textBox1.Text.Length, if that fails try textBox1.Text.Length() (not sure if Length is a direct variable or method)
ChingChong23 is offline  
Old 11/22/2009, 16:58   #8
 
elite*gold: 0
Join Date: Mar 2006
Posts: 98
Received Thanks: 9
Use textBox1.Length, without the semicolon.
Try: if ((i % 2) != 0) // Odd number
Diabox is offline  
Old 11/22/2009, 19:07   #9
 
elite*gold: 0
Join Date: Jun 2007
Posts: 145
Received Thanks: 8
Anyone Can tell me Full Codes Cause I dont understand :S
xxFastBoy is offline  
Old 11/22/2009, 19:13   #10
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,124
Received Thanks: 2,500
Quote:
Originally Posted by xxFastBoy View Post
Anyone Can tell me Full Codes Cause I dont understand :S
This is homework right? If thats the case then you should figure it out for yourself, although im alittle confused about why your writing this in C# when you dont really know the language at all.
Korvacs is offline  
Old 11/22/2009, 19:31   #11
 
elite*gold: 0
Join Date: Mar 2006
Posts: 98
Received Thanks: 9
Ok so here's the deal, you want to swap the characters if the string exists out of an odd number of characters (3), so ABC becomes CBA, and if it's an even number (2), it stays the same AB becomes AB. And if the string contains more than 3 characters, you want it to split it up in as many "3" character strings as you can and swap again, so in case of a 10-character string it needs to chop it in 3 seperate strings of 3 and 1 string of 1 character. Am I correct?

So first you need to check if the string contains either 2 or 3 characters or more. You would want to write a method for it. I'm not known with C# so I'll do it in java.


Code:
/*
 * Method which checks if the string consists out of more than 3 characters
 */
public static boolean moreThanThree(String myString) {
    int strl = myString.length();
    if (strl > 3) {
        return true;
    }
    else {
        return false;
    }
}
Ok now you have to write a method which swaps the contents of the string, I could do this in java, but I think you'll have a hard time converting it to C# since you're new to the language... It would be rather equal to the code which is given earlier.
Diabox is offline  
Old 11/22/2009, 19:52   #12
 
elite*gold: 0
Join Date: Jun 2007
Posts: 145
Received Thanks: 8
Quote:
Originally Posted by Korvacs View Post
This is homework right? If thats the case then you should figure it out for yourself, although im alittle confused about why your writing this in C# when you dont really know the language at all.
Ah Sorry its not only This

iam are in a project i think someone help me about my problem


xxFastBoy is offline  
Reply



« Gold Lotter | i need help »

Similar Threads
Fix the problem of software designed By Visual Basic to work on systems with Vista&7
07/08/2010 - Tutorials - 12 Replies
Dear Brothers All the brothers, users of Vista and Windows seven suffer from the problem of lack of work programs made by Visual Basic On their computer .. The problem lies in the two systems do not recognize some of the libraries and tools...
Visual Basic 2008 Problem
04/04/2010 - .NET Languages - 14 Replies
Hallo e*pvp coder, ich habe da ein Problem. http://img690.imageshack.us/img690/1824/13380409.jpg Neu installiert habe ich es schon. Da kam eine Meldung wegen Service Pack 1 oder so. Habe aber Service Pack 3. Gibts da irgendeinen Trick?...
Visual Basic - Kleines Problem/Frage
04/04/2010 - .NET Languages - 9 Replies
Hallo, ich war/bin gerade dabei bei VB 2008 eine Form zu designen. Wenn ich dieser Form jetzt ein Bild zuweise und dann ein Label hinzufüge, hat dieser Text einen Hintergrund und verdeckt das Bild. ...
Visual Basic Problem
12/29/2009 - .NET Languages - 0 Replies
hi ich hab hier noch probleme ich zeig hier mal nen ausschnitt: Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick Label1.Text = 0 End Sub
Basic GP/EXP bot
06/09/2009 - Combat Arms Hacks, Bots, Cheats & Exploits - 20 Replies
Basic GP & EXP bot What it does: 1. Finds an open game and joins it. 2. Presses Ready/Start and joins the game 3. Waits for the game to finish 4. Repeats Included features: - Built in lobby advertising so you can advertise your clan or...



All times are GMT +2. The time now is 09:06.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.