14 Replies - 620 Views - Last Post: 29 January 2013 - 09:47 PM Rate Topic: -----

#1 DamianMRLY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 27-December 12

Read txtbox and put in array?

Posted 28 January 2013 - 09:27 AM

Hi,

I want to read the content of the input textbox, and put it in an bytearray.
But i cant find an solution

Posted Image

Maby someone can help.

Thanxs in advance,

This post has been edited by modi123_1: 28 January 2013 - 09:34 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Read txtbox and put in array?

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,767
  • Joined: 12-June 08

Re: Read txtbox and put in array?

Posted 28 January 2013 - 09:34 AM

Well.. what have you tried? Why would you put a string in a byte array? What event is supposed to trigger this?
Was This Post Helpful? 0
  • +
  • -

#3 DamianMRLY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 27-December 12

Re: Read txtbox and put in array?

Posted 28 January 2013 - 09:43 AM

Well eventually i want to read an file and determine the frequenty of all bytes for my Huffman algorimth

Well eventually i want to read an file and determine the frequenty of all bytes for my Huffman algorimth
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5625
  • View blog
  • Posts: 12,064
  • Joined: 02-June 10

Re: Read txtbox and put in array?

Posted 28 January 2013 - 09:44 AM

Textbox has a .Text property - That's how you get the text that is in the textbox.
http://msdn.microsof...y/ms617604.aspx

It would therefore be a safe assumption that you haven't really taken any time to learn about C#. This is something covered by the 3rd chapter in any "Learn C# in 30 days" type of book.

As another expert here told another student (so well that he deserves credit for it):

View PostCurtis Rutland, on 09 July 2012 - 01:38 PM, said:

I hate to be the bearer of bad news, but there's a fundamental problem here: we're not a "intro to programming class" and we never can be. We can help you with specific problems, but what you're missing is the basic foundation. Go back to your instructor and explain to him/her that you don't understand and need help. Talk to your classmates. Find someone who can go over the book with you, in person, so you can understand what you are missing.


For now, you just need to work on learning the foundation basics. Don't try to architect programs until you are ready.


My standard beginner resources post - Updated JAN 2013


Plan your study route:
There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)


For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

  • First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover.
  • Do a dozen on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.
  • Learn to plan before you type.
  • THEN you start designing software with a purpose.



I don't learn from reading books: I learn by doing.
Spoiler


Newbie/Rookie said:

I have little/no programming experience but I need to write a program by Friday that does XYZ.
Spoiler



Resources, references and suggestions for new programmers.
Spoiler

Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3647
  • View blog
  • Posts: 11,415
  • Joined: 05-May 12

Re: Read txtbox and put in array?

Posted 28 January 2013 - 09:51 AM

Ouch! If you can't even read a string and get its characters, how do you expect to even write code to implement the Huffman encoding and decoding?
Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5625
  • View blog
  • Posts: 12,064
  • Joined: 02-June 10

Re: Read txtbox and put in array?

Posted 28 January 2013 - 09:55 AM

To be fair the OP did say 'eventually'. Its good to have goals.
The problem here is the OP is trying to drive on the freeway as his first time behind the wheel.

Trust us when we tell you to just learn and do the exercises in the books for now. Designing a program comes later.
Was This Post Helpful? 1
  • +
  • -

#7 DamianMRLY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 27-December 12

Re: Read txtbox and put in array?

Posted 28 January 2013 - 10:43 AM

Hahah ok i will take you're advise. Can recommomend any book in particular for learning programming in C#?
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,767
  • Joined: 12-June 08

Re: Read txtbox and put in array?

Posted 28 January 2013 - 10:46 AM

There's a pinned thread in the c# advanced section.
Was This Post Helpful? 0
  • +
  • -

#9 DamianMRLY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 27-December 12

Re: Read txtbox and put in array?

Posted 28 January 2013 - 10:49 AM

Okey thanxs for the advise, maby in a week or two i can ask more detailed questions if i have one:)
Was This Post Helpful? 0
  • +
  • -

#10 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5625
  • View blog
  • Posts: 12,064
  • Joined: 02-June 10

Re: Read txtbox and put in array?

Posted 28 January 2013 - 12:30 PM


My standard beginner resources post - Updated JAN 2013


Plan your study route:
There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)


For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

  • First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover.
  • Do a dozen on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.
  • Learn to plan before you type.
  • THEN you start designing software with a purpose.



I don't learn from reading books: I learn by doing.
Spoiler


Newbie/Rookie said:

I have little/no programming experience but I need to write a program by Friday that does XYZ.
Spoiler



Resources, references and suggestions for new programmers.
Spoiler

Was This Post Helpful? 1
  • +
  • -

#11 DamianMRLY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 27-December 12

Re: Read txtbox and put in array?

Posted 28 January 2013 - 02:52 PM

Thanxs for the advice, just subscripted on tutplus for the course! But i won't need the full 30 days for sure:)
Was This Post Helpful? 0
  • +
  • -

#12 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5625
  • View blog
  • Posts: 12,064
  • Joined: 02-June 10

Re: Read txtbox and put in array?

Posted 28 January 2013 - 03:37 PM

I love the confidence... But yes you will.
Was This Post Helpful? 1
  • +
  • -

#13 DamianMRLY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 27-December 12

Re: Read txtbox and put in array?

Posted 29 January 2013 - 04:32 PM

Hi,

I just must need to solve this little problem i've got here.

I got this code

        private void btn_Click(object sender, EventArgs e)
        {
            byte[] data = File.ReadAllBytes("a.txt");

            int[] totals = new int[256];

            foreach (char b in data)
            {
                ++totals[b];
            }
        }




It gives me this:
http://i45.tinypic.com/2nquqhi.png

But how can i show the frequency(occurrence) of each character in a.txt also?
Was This Post Helpful? 0
  • +
  • -

#14 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5625
  • View blog
  • Posts: 12,064
  • Joined: 02-June 10

Re: Read txtbox and put in array?

Posted 29 January 2013 - 05:52 PM

You're on the right track.

You'll have to loop through the array and count. No magic call that does the work for you.

So when you have a value of 97, increase the value in your array at the 97th index.

Give it a try and if it doesn't work, show us your updated code.
Was This Post Helpful? 0
  • +
  • -

#15 bboyzeez  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 143
  • Joined: 16-December 12

Re: Read txtbox and put in array?

Posted 29 January 2013 - 09:47 PM

View PostDamianMRLY, on 28 January 2013 - 10:43 AM, said:

Hahah ok i will take you're advise. Can recommomend any book in particular for learning programming in C#?



Look at the book called computing with C# and the .net framework by art gittleman amazing book I'm learning through it as beginner and if I can learn from it anyone can haha. Look around ur find a free copy lol
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1