✅ 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!
13 Replies
$screenshot
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.
I can see nothing of that photo
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
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
itSo how would that look like
sentence = sentence.Replace("a", "A");
etc
in fact, you could write it all like...
Thank youuu!!!
Just a question like as in hypothetically speaking
Could you use Variable names with every replace?
For the sentence
sure you could, but it would be messy
Ye I know but it would be easier if I would check it again you know
you'd have to do something like this
remember, each step needs to build on the last one
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?
you type
/close