[Help]Number Count[Solved]

Posts 31–36 of 36 · Page 3 of 3


for code below, outcome should be

Chars >= 0 to 16 , 1 Line
XXXXXXXX XXXXXXXX

Chars >= 27 to 32 , 2 Lines
XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX

Chars >= 32 to 48 , 3 Lines
XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX

Here is code
[php]
Dim Str As String = "3036373835"
Dim multipleOf As Integer
Dim numberofLines As Integer
If Str.Count >= 0 <= 16 Then
multipleOf = 16
numberofLines = 1
ElseIf Str.Count >= 17 <= 32 Then
multipleOf = 32
numberofLines = 2
ElseIf Str.Count >= 33 <= 48 Then
multipleOf = 48
numberofLines = 3
End If

Dim isSpace As Boolean = False
Dim finalStr As String = ""
If Str.Length < numberofLines * multipleOf Then
For i As Integer = Str.Length To (numberofLines * multipleOf) - 1
Str += "0"
Next
End If
For i As Integer = 1 To Str.Length
If i Mod 8 = 0 Then
If isSpace Then
finalStr += Mid(Str, i, 1)
finalStr += vbCrLf
isSpace = False
Continue For
Else
finalStr += Mid(Str, i, 1)
finalStr += " "
isSpace = True
Continue For
End If
Else
If Mid(Str, i, 1) = " " Then
finalStr += "0"
Else
finalStr += Mid(Str, i, 1)
End If
End If
Next
MsgBox(finalStr)
[/php]
when i had 18 characters.
it did not add 0s.

i fixed it yay!!

Here is the change:
Code:
 Dim Str As String = TextBox3.Text
        Dim multipleOf As Integer
        Dim numberofLines As Integer
        If Str.Count <= 16 Then
            multipleOf = 16
            numberofLines = 1
        ElseIf Str.Count <= 32 Then
            multipleOf = 16
            numberofLines = 2
        ElseIf Str.Count <= 48 Then
            multipleOf = 16
            numberofLines = 3
        End If
Good to hear, see the correction overkill with the second prerequisite
thanks nextgen1

Dim Str As String = TextBox3.Text
Dim multipleOf = 16
Dim numberofLines As Integer
If Str.Count <= 16 Then
numberofLines = 1
ElseIf Str.Count <= 32 Then
numberofLines = 2
ElseIf Str.Count <= 48 Then
numberofLines = 3
End If

Is there a way to increase the elseif statements without doing
ElseIf Str.Count <= 64 Then
numberofLines = 4
ElseIf Str.Count <= 80 Then
numberofLines = 5
...
continues..



---------

is there a statement for if something is a multiple of 16...
I need help on a simple alteration of the code.

Basically here is the string = "123902831098309821039813098"

12390283 10983098 21039813 09800000

The string will be presented in a straight line with spaces for every 8 character and additional 0s added to the end to form 8 characters.
Quote Originally Posted by ppl2pass View Post
I need help on a simple alteration of the code.

Basically here is the string = "123902831098309821039813098"

12390283 10983098 21039813 09800000

The string will be presented in a straight line with spaces for every 8 character and additional 0s added to the end to form 8 characters.
Oh some cool coding in my absense. Nice work Next

I create a sub-procedure for this:


[php]Sub completezeros()

Dim Str As String = "123902831098309821039813098"
Dim finalStr As String = ""

While Not Str.Length Mod 8 = 0
Str += "0"
End While
For i As Integer = 1 To Str.Length
If i Mod 8 = 0 Then
finalStr += Mid(Str, i, 1)
finalStr += " "
Continue For
Else
finalStr += Mid(Str, i, 1)
End If
Next

MsgBox(finalStr)

End Sub[/php]

This will do what you just said
Posts 31–36 of 36 · Page 3 of 3
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us