Hello all,
I'm trying to do a small application that has this string as an imput "11010" and my goal is to divide the string and load it into an array in this way:
[1][11][110][11010]
The code that I came up with is this: - Public Class Form1
-
Dim prefixes(10000) As String
-
Dim s As String
-
Dim count As Integer
-
Dim j As Integer
-
Dim pre_lenght As Integer
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
TextBox1.Text = "11010"
-
s = TextBox1.Text
-
pre_lenght = TextBox1.TextLength
-
j = pre_lenght
-
While j > 0
-
For Me.count = 0 To count = pre_lenght
-
prefixes(Me.count) = s.Substring(pre_lenght - j)
-
j = j - 1
-
Next
-
End While
-
Label1.Text = j
-
Label2.Text = pre_lenght
-
Label3.Text = prefixes(0)
-
End Sub
-
End Class
For some reason it is just storing information in the position 0 of prefixes() and not in any other position,
If someone have any idea of how to solve this problem please let me know.
Thanks.
Daniel.
7 1480
Hello all,
I'm trying to do a small application that has this string as an imput "11010" and my goal is to divide the string and load it into an array in this way:
[1][11][110][11010]
The code that I came up with is this:
Public Class Form1
Dim prefixes(10000) As String
Dim s As String
Dim count As Integer
Dim j As Integer
Dim pre_lenght As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = "11010"
s = TextBox1.Text
pre_lenght = TextBox1.TextLength
j = pre_lenght
While j > 0
For Me.count = 0 To count = pre_lenght
prefixes(Me.count) = s.Substring(pre_lenght - j)
j = j - 1
Next
End While
Label1.Text = j
Label2.Text = pre_lenght
Label3.Text = prefixes(0)
End Sub
End Class
for some reason it is just storing information in the position 0 of prefixes() and not in any other position,
If someone have any idea of how to solve this problem please let me know.
Thanks.
Daniel.
likely your culprit: -
For Me.count = 0 To count = pre_lenght
-
Do you want to store [1101] as well? -
' VBA
-
-
Sub Test()
-
Dim curr_line As String, i As Integer
-
-
curr_line = "11010"
-
-
For i = 1 To Len(curr_line)
-
Debug.Print Mid(curr_line, 1, i)
-
Next i
-
End Sub
wouldnt it be easier with something like: - dim Str1 as string = "11010"
-
dim Arr() as string
-
dim i as long
-
redim arr(1 to len(str1))
-
for i = 1 to len(str1)
-
arr(i) = left(str1,i)
-
next
HTH
Sorry kadghar, no Left() function any more, remember? Bummer.
Idazaa1 would need to use the substring one instead.
Sorry kadghar, no Left() function any more, remember? Bummer.
Idazaa1 would need to use the substring one instead.
lol
sorry, instead of left(string,integer)
you can always use mid(string, 1, integer)
happy now?
you can always use mid(string, 1, integer)
happy now?
Not really. That's VB6. Don't think it'll work in the version under discussion. :P
Not really. That's VB6. Don't think it'll work in the version under discussion. :P
that's true, i forgot MID wasnt good anymore. It'll take time till i get used to Substring
Then instead of Left(string, length), it should be string.substring(1,length), right?
=( it's like learning to walk again.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Don Starr |
last post by:
When applied to a string literal, is the sizeof operator supposed to return the size of the string
(including nul), or the size of a pointer?
For example, assuming a char is 1 byte and a char *...
|
by: al |
last post by:
char s = "This string literal";
or
char *s= "This string literal";
Both define a string literal. Both suppose to be read-only and not to be
modified according to Standard. And both have...
|
by: songkv |
last post by:
Hi,
I am trying to reassign an array of char to a string literal by
calling a function.
In the function I use pointer-to-pointer since I want to reassign the
"string array pointer" to the string...
|
by: spike |
last post by:
How do i reset a string?
I just want to empty it som that it does not contain any characters
Say it contains "hello world" at the time...
I want it to contain "". Nothing that is..
Thanx
|
by: Simon Schaap |
last post by:
Hello,
I have encountered a strange problem and I hope you can help me to
understand it. What I want to do is to pass an array of chars to a
function that will split it up (on every location where...
|
by: Bob |
last post by:
I have a function that takes in a list of IDs (hundreds) as input parameter
and needs to pass the data to another step as a comma delimited string. The
source can easily create this list of IDs in...
|
by: Jeff Johnson |
last post by:
Hi,
I've begun converting an ASP site over to .NET and I'm a novice at both the
new platform as well as C#.
I have a COM+ object that returns a string array when it is called. The
size of...
|
by: Chad Myers |
last post by:
I've been perf testing an application of mine and I've noticed that there
are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String
instances being created.
I've done some...
|
by: Zordiac |
last post by:
How do I dynamically populate a string array?
I hope there is something obvious that I'm missing here
Option Strict On
dim s() as string
dim sTmp as string = "test"
dim i as integer
...
|
by: Shhnwz.a |
last post by:
Hi,
I am in confusion regarding jargons.
When it is technically correct to say.. String or Character Array.in c.
just give me your perspectives in this issue.
Thanx in Advance.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |