battle programmers alliance

battle programminga forum for elite programmerswith extreme will powerto sharpen theire skills
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Search
 
 

Display results as :
 
Rechercher Advanced Search
Latest topics
» xamarin c# manual image app walkthrough
Sat Aug 12, 2017 2:08 pm by Moti Barski

» win10 shortcut keys
Wed Aug 09, 2017 2:40 am by Moti Barski

» vb.net region
Sat Aug 05, 2017 12:25 am by Moti Barski

» visual studio 2017 xamarin c# hello world walkthrough
Sat Jul 29, 2017 11:34 am by Admin

» gear s3 frontier s voice command list
Sat Jul 22, 2017 7:07 pm by Moti Barski

» how to use magnet links
Wed Jun 28, 2017 3:41 am by kurosen

» evolution of code
Mon Jun 12, 2017 12:08 am by kurosen

» chicken bot
Sat Apr 29, 2017 11:09 am by Moti Barski

» vb.net convert to binary
Thu Apr 27, 2017 7:48 am by Moti Barski

August 2017
SunMonTueWedThuFriSat
  12345
6789101112
13141516171819
20212223242526
2728293031  
CalendarCalendar
Social bookmarking
Social bookmarking Digg  Social bookmarking Delicious  Social bookmarking Reddit  Social bookmarking Stumbleupon  Social bookmarking Slashdot  Social bookmarking Yahoo  Social bookmarking Google  Social bookmarking Blinklist  Social bookmarking Blogmarks  Social bookmarking Technorati  

Bookmark and share the address of battle programmers alliance on your social bookmarking website
Share | 
 

 vb.net text editing series

View previous topic View next topic Go down 
AuthorMessage
Moti Barski

avatar

Posts : 79
Join date : 2011-08-02

PostSubject: vb.net text editing series   Wed Jan 30, 2013 7:08 am

overlord mode has been enabled

vb.net text aligner

the following program is a text aligner.
the program gets a text via the richtextbox conrol and adds new lines
so that no line's length surpasses the maximum length set by the end user.
the program also takes space characters under consideration, in order to not
break words.


form controls :

button
richtextbox
2 textboxes

all of the control properties are set to default.

paste the to be aligned text using ctrl+v in the richtextbox
set the line limit in textbox1 using an integer
set the minimum characters per line in textbox2 using an integer

and click the button.

Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '* multiline textbox
        Dim nEnter As String = "qwertyuiopasdfghjklzxcvbnm,.1234567890-=\ "
        nEnter &= "`~!@#$%^&*()_+|QWERTYUIOPASDFGHJKLZXCVBNM<>?:{}[];'./"
        nEnter &= """"
        Dim result As String = ""
        Dim lineLimit As Byte
        Dim minCharsPerLine As Byte
        Try
            minCharsPerLine = TextBox2.Text
        Catch ex As Exception
            minCharsPerLine = 5
        End Try
        Dim ch As Char = ""
        Try
            lineLimit = TextBox1.Text
        Catch ex As Exception
            lineLimit = 5
        End Try
        Dim counter As Integer
        counter = 0
      For index = 0 To RichTextBox1.TextLength - 1
            ch = RichTextBox1.Text(index)
            If Not nEnter.Contains(ch) Then
                counter = -1
            End If
            If ch = " " And counter > minCharsPerLine Then
                ch = vbCrLf
                counter = -1
            End If
            If counter = lineLimit Then
                counter = 0
                result &= vbCrLf
            End If
            result &= ch
            counter += 1
        Next
        RichTextBox1.Text = result
    End Sub
End Class
Back to top Go down
View user profile
Moti Barski

avatar

Posts : 79
Join date : 2011-08-02

PostSubject: vb.net convert enter to br html tag   Fri Feb 01, 2013 7:15 pm

the following program replaces all new lines in a rich text box to <br> or
new line + <br> respective to button1 or button2 (the button clicked)

Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' this button replaces all new lines with <br>
        Dim nEnter As String = "qwertyuiopasdfghjklzxcvbnm,.1234567890-=\ "
        nEnter &= "`~!@#$%^&*()_+|QWERTYUIOPASDFGHJKLZXCVBNM<>?:{}[];'./"
        nEnter &= """" ' not enter
        Dim result As String = ""
        Dim ch As Char = ""
        For i = 0 To RichTextBox1.TextLength - 1
            ch = RichTextBox1.Text(i)
            If nEnter.Contains(ch) Then
                result &= ch
            Else
                result &= "<br>"
            End If
        Next
        RichTextBox1.Text = result
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ' this button replaces all new lines with new line & <br>
        Dim nEnter As String = "qwertyuiopasdfghjklzxcvbnm,.1234567890-=\ "
        nEnter &= "`~!@#$%^&*()_+|QWERTYUIOPASDFGHJKLZXCVBNM<>?:{}[];'./"
        nEnter &= """" ' not enter
        Dim result As String = ""
        Dim ch As Char = ""
        For i = 0 To RichTextBox1.TextLength - 1
            ch = RichTextBox1.Text(i)
            If nEnter.Contains(ch) Then
                result &= ch
            Else
                result &= vbCrLf & "<br>"
            End If
        Next
        RichTextBox1.Text = result
    End Sub
End Class
Back to top Go down
View user profile
Moti Barski

avatar

Posts : 79
Join date : 2011-08-02

PostSubject: vb.net basic text aligner   Sat Feb 02, 2013 9:29 pm

the following program is a text aligner that sets all lines in a text to
a set amount of characters. it doesn't give any special treatment to spaces (" "),
in other words, words can be broken by it.

form controls :
button
richtextbox
textbox

all of the control's properties are set to default

type the maximum line length in the textbox using an integer.
paste the text on the richtextbox using ctrl+v and click the button.

Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '* multiline textbox
        Dim nEnter As String = "qwertyuiopasdfghjklzxcvbnm,.1234567890-=\ "
        nEnter &= "`~!@#$%^&*()_+|QWERTYUIOPASDFGHJKLZXCVBNM<>?:{}[];'./"
        nEnter &= """"
        Dim result As String = ""
        Dim lineLimit As Byte
        Dim ch As Char = ""
        Try
            lineLimit = TextBox1.Text
        Catch ex As Exception
            lineLimit = 5
        End Try
        Dim counter As Integer
        counter = 0
        For index = 0 To RichTextBox1.TextLength - 1
            ch = RichTextBox1.Text(index)
            If Not nEnter.Contains(ch) Then
                counter = -1
            End If
            If counter = lineLimit Then
                counter = 0
                result &= vbCrLf
            End If
            result &= ch
            counter += 1
        Next
        RichTextBox1.Text = result
    End Sub
End Class
Back to top Go down
View user profile
Moti Barski

avatar

Posts : 79
Join date : 2011-08-02

PostSubject: vb.net word sorter   Wed May 01, 2013 7:12 am

form controls :
button
richtextbox
listbox

Code:
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '* multiline textbox
        Dim nEnter As String = "qwertyuiopasdfghjklzxcvbnm,.1234567890-=\"
        nEnter &= "`~!@#$%^&*()_+|QWERTYUIOPASDFGHJKLZXCVBNM<>?:{}[];'./"
        nEnter &= """"
        Dim word As String = ""
        Dim ch As Char = ""
        For index = 0 To RichTextBox1.TextLength - 1
            ch = RichTextBox1.Text(index)
            If nEnter.Contains(ch) Then
                word &= ch
            Else
                If Not ListBox1.Items.Contains(word) And word <> "" Then
                    ListBox1.Items.Add(word)
                End If
                word = ""
            End If
        Next
        ListBox1.Items.Add(word)
        ListBox1.Sorted = True
        RichTextBox1.Text = ""
        For I = 0 To ListBox1.Items.Count - 1
            RichTextBox1.Text &= (ListBox1.Items(I).ToString) & vbCrLf
        Next
    End Sub
End Class
study
Back to top Go down
View user profile
Moti Barski

avatar

Posts : 79
Join date : 2011-08-02

PostSubject: vb.net line based word sorter   Fri May 03, 2013 5:38 am

the following is a line based word sorter, each line is sorted.
form controls :
listbox
button
richtextbox

Code:
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '* multiline textbox
        Dim nEnter As String = "qwertyuiopasdfghjklzxcvbnm,.1234567890-=\ "
        nEnter &= "`~!@#$%^&*()_+|QWERTYUIOPASDFGHJKLZXCVBNM<>?:{}[];'./"
        nEnter &= """"
        Dim word As String = ""
        Dim ch As Char = ""
        For index = 0 To RichTextBox1.TextLength - 1
            ch = RichTextBox1.Text(index)
            If nEnter.Contains(ch) Then
                word &= ch
            Else
                If Not ListBox1.Items.Contains(word) And word <> "" Then
                    ListBox1.Items.Add(word)
                End If
                word = ""
            End If
        Next
        ListBox1.Items.Add(word)
        ListBox1.Sorted = True
        RichTextBox1.Text = ""
        For I = 0 To ListBox1.Items.Count - 1
            RichTextBox1.Text &= (ListBox1.Items(I).ToString) & vbCrLf
        Next
    End Sub
End Class
Back to top Go down
View user profile
Moti Barski

avatar

Posts : 79
Join date : 2011-08-02

PostSubject: vb.net number lines   Sun May 05, 2013 10:33 am

form controls :
button
richtextbox
textbox

paste the text in the rich textbox
type in the textbox the start number from which the text's lines will be numbered
click the button

Code:
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' this button numbers the lines in the richtextbox
        Dim nEnter As String = "qwertyuiopasdfghjklzxcvbnm,.1234567890-=\ "
        nEnter &= "`~!@#$%^&*()_+|QWERTYUIOPASDFGHJKLZXCVBNM<>?:{}[];'./"
        nEnter &= """" ' not enter
        Dim result As String = ""
        Dim ch As Char = ""
        Dim x As Integer = 0
        Try
            x = TextBox1.Text - 1
        Catch ex As Exception

        End Try
        RichTextBox1.Text = vbCrLf & RichTextBox1.Text 'if you take out this line
        'add enter in the richtextbox before clicking the button
        For i = 0 To RichTextBox1.TextLength - 1
            ch = RichTextBox1.Text(i)
            If nEnter.Contains(ch) Then
                result &= ch
            Else
                x += 1
                result &= vbCrLf & (x).ToString & ". "
            End If
        Next
        RichTextBox1.Text = result
    End Sub
End Class
monkey
Back to top Go down
View user profile
 
vb.net text editing series
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» how to select text from a disabled field?
» How to use storetext and verify text? It is failing for me..
» Entering a time stamp in comment / text box?
» WORLD SERIES TICKETS GIVEAWAY *Canada and usa only*
» Need to do a simple Left Click in a text box

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: battle programming-
Jump to: