|
Mo Chips wrote: i figured out how to get the correct count
That's the harder part done...
Mo Chips wrote: i dont know how to get it to correctly display ... in the result control
What control are you using to display the result? How do you have the result in memory - in an array, a dictionary, a list or just a count variable for each letter?
Another thought is how are you handling upper/lower case letters? Is it going to be used for non standard characters or digits etc...
This is part of the art of programming. Predicting and handling scenarios that could possibly cause your code to fail.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
IM familiar with C so I have a count set up for each letter... Ive done all this in the button function..
Im not familiar with any Visual Programming Languages so the prob im having is on the buttonclick event having the reults show in a textboxt... i know i should use "textbox.text =" but i dont know the code to have the multiple counts i have in memory to show in that textbox
|
|
|
|
|
I've shown you how to append to the text above.
I'd be tempted to use a ListBox for this and just add a new Item for each one, for two reasons.
1. It's easier
2. It's not editable by the end user.
There are other issues with updating strings that way too - if you want to persist with a TextBox, consider using a StringBuilder and calling its ToString method to update the text box just before you return from the method.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanx Davey.... Im going to try the listbox.. Like i said ive NEVER used any Visual C# before so all i know is textbox thru watching youtube videos lol...
To be honest this program im doing is to get accepted into a class to learn Visual C#.. By completing this satisfactory Ill get the opportunity to learn the Language for free.. With this recession going on free always sounds good.....
so Im just tryna feel my way thru with trial and error.. if this was Pascal i would have been finished lol but i guess u can see how outdated i am
|
|
|
|
|
textbox2.Clear();
string input = textbox1.Text;
for(int i = 1; i <= 26; i++)
{
char letter = (char)(64 + i);
int count = 0;
foreach(char c in input)
{
if(char.ToUpper(c) == letter)
count++;
}
textbox2.AppendText("There are " + count + " " + letter + "'s" + Environment.NewLine);
}
...this can be called from you button event handler... easy
Life goes very fast. Tomorrow, today is already yesterday.
modified on Tuesday, May 12, 2009 10:20 AM
|
|
|
|
|
First off the idea is to give points as it is homework and second I would look at your solution again as it's messy. You end up doing 26 loops over the length of the string!
Think of a different way, use a list or dictionary.
|
|
|
|
|
hopingToCode wrote: First off the idea is to give points as it is homework
what else can demonstrate a solution as good as an example?
hopingToCode wrote: I would look at your solution again
So if you would look at my solution again then you must like it
hopingToCode wrote: You end up doing 26 loops over the length of the string!
Guess what, I wrote it so I already know its not the best solution, the point was it was short code to exemplify a possible solution
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
To be honest this program im doing is to get accepted into a class to learn Visual C# so its technically not a homework assignment because im not in a class.....
By completing this satisfactory I'll get the opportunity to learn the Language for free.. With this recession going on free always sounds good.....
Ive never coded in visual C#.... ive done some Pascal and C in HS ive just been tryna teach myself because i came across this opportunity to be taught the Language for Free...
I really appreciate everyone's help... but if someone will tell me how to keep my reults from being displayed on one line ill be the happiest guy on the planet
|
|
|
|
|
Mo Chips wrote: how to keep my reults from being displayed on one line
If you use a ListBox as suggested earlier then assuming your ListBox is called listBoxResults and your text is in a string called yourResultString then:
listBoxResults.Items.Add(yourResultString); Doesn't get much easier.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I understand what you're saying but it's also bad to get into bad programming habits, so better to optimism as much as possible.
I just had a go at doing it and it took me about 10 min
|
|
|
|
|
Its displaying the results all on oneline... how do i get it on seperate lines??
|
|
|
|
|
sorry... see the edited code.
But adding a new line in a string is something you should know before doing anything like this... so if you are willing to learn as you said then you should go to whomever set the homework and ask for some good book/websites for the basics.
...or you could use a listView then you wouldnt need the newlines
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi there,
Is there a way to have the TabControl on a WinForm without showing the Tab header?
Kind regards,
Jr
|
|
|
|
|
Yes, use a panel!
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Why would you want to?? You could just use different panels!
|
|
|
|
|
I think Ashfield and hopingtocode are (understandably) confused as to why you want to do this. If you created a TabControl without a tab header, how is the user going to select the tab division they want to veiw?
What are you trying to achieve?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Well, I'm trying to create a wizard like interface. I will then add a Next and Previous button and provide the user with the ability to navigate through the pages.
|
|
|
|
|
There are some wizard controls out there but I would use panels to do the information display. Tab is for when you want them all viewable
|
|
|
|
|
OK. Create a form, with a panel which occupies most of space, leaving enough for your buttons - lets call it panelSpace.
Create your individual panel fillers by Project...Add...NewItem... UserControl - this creates a blank panel filler - lets call it panelA. Set its Dock property to fill the panel, and place your controls.
When you want to display the items from panelA:
panelSpace.Controls.Clear();
panelSpace.Controls.Add(panelA);
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
OriginalGriff wrote: Set its Dock property to fill the panel,
No I'm an idiot - it doesn't have a dock property - ignore that bit! Must be a tuesday again...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Thanks Original Griff for this. This works!
|
|
|
|
|
You're welcome.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Try that derived class form TabControl. It simply overrides the DisplayRectangle and adds a ShowTab Property for your new TabControl class. Does it help you ?
public class MyTabControl : TabControl
{
public override Rectangle DisplayRectangle
{
get
{
if (showTabs)
{
return base.DisplayRectangle;
}
else
{
return new Rectangle(0, 0, Width, Height);
}
}
}
#region Properties
private bool showTabs = true;
[Category("Apparence"),
Description("Indique si les onglets s'affichent."),
DefaultValue(true)]
public bool ShowTabs
{
get { return showTabs; }
set
{
showTabs = value;
RecreateHandle();
}
}
#endregion
}
|
|
|
|
|
Pyrrhon you're a Genius - your answer was exactly what I was looking for. Thank you again.
|
|
|
|
|
I'm glad to help you. Just a little thing : when you add a lot of TabPages, 2 tabpage scroll buttons appear in the TabControl. To hide them, just set Multiline=true. However I suppose you knew it.
Bye
|
|
|
|