Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Some Small Problems That I Need Some Help With...

Featured Replies

Posted

Hoy there fellas, I have this little problem here..... Im stuck with a text-line problem, so here it goes:

I want to code an app which automatically selects a new line for each lets say 12 chars has been written, and then continue so on....

Anyone with any suggestions that might could help me out?

/Dearest, n00b

Well without knowing exactly what your doing it's hard to say. Are you wanting like an array split or just a loop and process 12 at a time?

  • Author

I want a some sorta loop that processes 12 chars at each time....

That beeing said, I mean ofc that i want the code to work while im typing into the textbox....

/n00b

cant you yust "count" length of entered text, and when its dividable with 12 (or whatever you need) just add new line character to it?!

  • Author

As Ted said, like a line break wich is automatic ;)

@ChupaChu:

Well, that has been my solution so far - but as we all know, that would not work properly as it will by "accident" divide some of the written text :(

@EVERYONE:

A good solution for this errornous problem would be much appreciated, thx :)

/Regards, n00b

Did you try and use the TextChanged property? In that, for the current line of that textbox/richtextbox you can count the entered characters, and if that is 12 then textbox1.Text += Environment.Newline;

Think this should help.

Oricode.

  • Author

@oricode:

Thought of that, and tested ofc MANY times - but as you can imagine, it didnt exactly work:

for (int i = 0; i < textBox2.Lines.Length; i++)

{

if (textBox2.Lines.Length == 12)

{

textBox2.Text += Environment.NewLine;

}

}

It will only ****-up, and stop working.... So im still stuck im afraid :/

/n00b

why it stops working?

does it mean that iw works ok until "some" event accours?

  • Author

Well, its stops working because it cannot read from "current" line only....

That is my biggest issue, and therefor Im seeking help for it ;)

/n00b

Ok that code won't work. Because it will enter an infinite loop on each text change and hang! Try this instead, somewhat "not-so perfect", but working 100% for your problem.

Declare globally ,  int j=0;
for (int i = 0; i < textBox1.Lines.Length; i++)
{
if (j == i)
{
if (textBox1.Lines[i].Length == 12)
{
SendKeys.Send("{ENTER}");
j = i+1;
}
}
}

If you want to improvise it you can have a look here :

http://www.codeproject.com/vb/net/textbox_line_limit.asp

Oricode.

Edited by oricode

  • Author

@Oricode:

Thx alot mate, helps me very much :D

Now I need to figure the more advanced parts out myself somehow :P

/n00b

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.