C
C#2d ago
~Nost~

✅ New to c# using Visual studio(WindowsFormsApp)

Hi everyone I've been trying to code something, if u put a sentence in a text box and u click a button that it will automatically put all vowels in capital letters in another text box and then all Consonants in capital letters in another text box. Can anyone help me with this code? Tell me what I did wrong, give me a code I can use or any help would be appreciated!
No description
No description
13 Replies
Buddy
Buddy2d ago
$screenshot
MODiX
MODiX2d ago
If you want to share code, please copy and paste the code into a markdown code block in your discord post, or paste the code into https://paste.mod.gg/ and share a link to it in your discord post. If want to share a screenshot, please do not take a photo of your computer screen with your phone or camera. Instead see https://www.take-a-screenshot.org/ for how to take a screen capture on your device. You may want to crop the image before pasting it into your discord message.
Scarlet
Scarlet2d ago
I can see nothing of that photo
~Nost~
~Nost~OP2d ago
Okay sorry guys I didn't know it's my first time I'll copy paste in a bit namespace Vreemde_klinkers { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void omzetButton_Click(object sender, EventArgs e) { string sentence = Convert.ToString(zinTextBox.Text); string aCapital = sentence.Replace("a", "A"); string eCapital = sentence.Replace("e", "E"); string iCapital = sentence.Replace("i", "I"); string oCapital = sentence.Replace("o", "O"); string uCapital = sentence.Replace("u", "U"); klinkerTextBox.Text = Convert.ToString(sentence); } private void Form1_Load(object sender, EventArgs e) { } } } This is the code I have but it doesn't work lol I think I need to restart
Pobiega
Pobiega2d ago
string.Replace returns the changed string strings in C# are immutable so you do the 5 replacements individually, not all at once, and you never use the result of either of them also, TextBox.Text is already a string, you dont need to Convert.ToString it
~Nost~
~Nost~OP2d ago
So how would that look like
Pobiega
Pobiega2d ago
sentence = sentence.Replace("a", "A"); etc in fact, you could write it all like...
klinkerTextBox.Text = zinTextBox.Text
.Replace("a", "A")
.Replace("e", "E")
.Replace("i", "I")
.Replace("o", "O")
.Replace("u", "U");
klinkerTextBox.Text = zinTextBox.Text
.Replace("a", "A")
.Replace("e", "E")
.Replace("i", "I")
.Replace("o", "O")
.Replace("u", "U");
~Nost~
~Nost~OP2d ago
Thank youuu!!! Just a question like as in hypothetically speaking Could you use Variable names with every replace? For the sentence
Pobiega
Pobiega2d ago
sure you could, but it would be messy
~Nost~
~Nost~OP2d ago
Ye I know but it would be easier if I would check it again you know
Pobiega
Pobiega2d ago
var source = "hello my name is Steve";

var capA = source.Replace("a", "A");
var capE = capA.Replace("e", "E");
var capI = capE.Replace("i", "I");
var source = "hello my name is Steve";

var capA = source.Replace("a", "A");
var capE = capA.Replace("e", "E");
var capI = capE.Replace("i", "I");
you'd have to do something like this remember, each step needs to build on the last one
~Nost~
~Nost~OP2d ago
I see Thank you for everything So it's my first time making a post what do I do with it now that everything is solved?
Pobiega
Pobiega2d ago
you type /close
Want results from more Discord servers?
Add your server