I'm trying to make a integer to string and also string to integer. Integer to string is what I want because if I finish integer to string I think I can reverse it.
Here is I have a wrong output. I likely created a number system in string like how you make a binary or etc. in my code it like this.

(a To 9) After
(b(a to 9) to 9(a to 9) After
(b(a(a to 9) to 9(a to 9)) To 9(a(a to 9) to 9(a to 9))

After First Set Of Characters The First Character Will Become (1 or b) like a number
0 to 9
1(0 to 9)
0 1 2 3 4 5 6 7 8 9 10 .... 99 100 ' it will not get 00 or 000 thats how like my code is.

Code I Come Up:

    Private Function Integer_To_String(ByVal Number As Integer, ByVal Chars As List(Of String)) As String

        Dim Character_String As New List(Of Integer)
        Dim Character_Count As Integer = Chars.Count
        Dim Left As Integer = Number
        Dim Str As String = ""

        While True

            Character_String.Add(Left Mod Character_Count)
            Left -= (Left Mod Character_Count)
            If Not Left = 0 Then
                Left /= Character_Count
                Exit While
            End If

        End While

        For i = 0 To Character_String.Count - 1
            Str &= Chars(Character_String.Item(Character_String.Count - 1 - i))

        Return Str

    End Function

Public Function LoadCharacters(ByVal Letters As Boolean, ByVal Numbers As Boolean, ByVal Symbols As Boolean) As List(Of String)

    Dim L As New List(Of String)

    If Symbols = True Then

        For i = 3 To 8

        For i = 11 To 27

        For i = 33 To 47

        For i = 58 To 64

        For i = 91 To 96

        For i = 123 To 126

        For i = 130 To 140

        For i = 145 To 156

        For i = 158 To 159

        For i = 161 To 255

    End If

    If Letters = True Then

        For i = 65 To 90



        For i = 65 To 90



    End If

    If Numbers = True Then

        For i = 0 To 9



    End If

    Return L

End Function

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Characters = LoadCharacters(False,True,False)

End Sub

I want
0 to 9 After
0(0 to 9) to 9(0 to 9)
0(0(0 to 9) to 9(0 to 9)) to 9(0(0 to 9) to 9(0 to 9))

Recommended Answers

All 19 Replies

ummmmmm. Anyone can help me?

Did you ever tried MyInt.ToString()? Or even 12345.ToString()?

ddanbe I'm trying to create my own character set. It's like number to letter. Not making the integer to string. My mistake.

Somehow I think we are getting lost in the explanation which is unclear. I can't make heads or tails out of your description. Can you perhaps just give us some sample input and what output you expect to get? I suggest you avoid terms such as "like" because what I am looking for is exact input and exact output.

characterset = LoadCharacters(true,true,false)
This is the output of the current code: http://pastebin.com/DgvyrsDw
This is the output of I want to do: http://pastebin.com/5BEgX6Wf
The number represent the characters.
dim str as string = Integer_To_String(0,characterset)
the str should get "a".the 0 is the given
in 3906 line is where the difference between the two of them starts.
they are different because when the INTEGER is greater than the characters in the list it will start with "b" not "a".

"99" after
"ba" it should be "aa"

That's not what I asked for and your explanation still does not make sense (I'll assume language diffferences). I asked for sample input and sample output but perhaps we can work with this. What you have is a straight mapping of a continuous set of integers to string. I can't see any obvious way of generating the mapping via code other than creating an array of integers and just indexing to get the resulting string. For example, if you take your list and create a file with one line per entry as in


then you can define

Private map() As String = = System.IO.File.ReadAllLines("map.txt")

To convert an integer to its corresponding string you just do

If num >= 0 and num <= Ubound(map) Then
    str = Map(num)
    str = "?"
End If

I have no idea how this relates to

(b(a(a to 9) to 9(a to 9)) To 9(a(a to 9) to 9(a to 9))

I dont want something like because i think it will consume too much space. I also want to have a String_To_Integer the opposite of this if i write something like "HelloAsskilled21" it will be converted to number, right. So if I try your idea it will make a huge number of line that will make the file hard to read and also the file has too much size just for it to get the text "HelloAsskilled21".
So any idea? In my code in the Integer_To_String the output is just a bit off. but my code works, just a bit of problem i think.

It will take less space than creating code for each special case. Your mapping is not reversible. For example, how will you determine if the string "aba" should be grouped as "a", "b", "a", or "a", "ba"?

Jim. This is the opposite of my current code.

    Private Function String_To_Integer(ByVal Str As String, ByVal Chars As List(Of String)) As Decimal

        Dim Character_Integer As New List(Of Decimal)
        Dim Sum As Integer = 0
        For Each S As String In Str
            For i = 0 To Chars.Count - 1
                If S = Chars.Item(i) Then
                    Exit For
                End If
        If Character_Integer.Count > 1 Then
            Dim Left As Decimal = 1
            For i = 0 To Character_Integer.Count - 1
                Dim Current As Decimal = Character_Integer.Item(Character_Integer.Count - 1 - i)
                If i = 0 Then
                    Left = Current
                    Left += (Chars.Count ^ (i)) * Current
                End If
            Return Val(Left)
        ElseIf Character_Integer.Count = 0 Then
            Return 0
            Return Val(Character_Integer.Item(0))
        End If

    End Function

It can be reverse.

Try my code. there is still a problem. If you input 62 the output in my current code is "ba" but it should be "aa" This problem is in Integer_To_String. And also a problem in the String_To_Integer. if your first letter in your input is "a" and the characters is more than "1" like "ab" there is 2 letter and the first one is "a". Its an error or a wrong output. it output 0 if you input like that.

According to your earlier post, 62 should translate to ba. My point is that once you have ba how do you know if it should translate back to 62 or 1 (b) and 0 (a)?

I don't understand your question. But, The code I created is just a trial and error after trying many times of doing it it just came like that before i know it..... The link you put is the output of my current code which is the problem the output should be really this.

In my String_To_Integer I just use math in there. I think of a formula of how to do it back to integer by reversing the code in my Integer_To_String And Translating the math into a code

fdj = (62 * 3 + 9) + ((62 * 62) * 5))
5 = "f"
3 = "d"
9 = "j"
62 = Character Count
(62'The Character Count' * 3'The d') + ((62 * 62)'I get 62 * 62 because its the second number in the list' * 5'The f')) + 9'The Extra Or J'
(62 * 3) + ((62 * 62) * 5)) + 9 ' Without Explanation

This is where I base its the math I created

Sorry about that. I followed the wrong link, but the problem is the same. According to the "correct" mapping, 63 maps to ab. But there is no unique inverse mapping. ab could map back to 63 or to 0, 1. You can't get back to where you started because there is no way to determine how to parse the strings. Here's an example.

124, 868, 868 = ba na na (banana)
1, 0, 13, 0, 13, 0 = b a n a n a (banana)
1, 75, 75, 0 = b an an a (banana)

The mapping is not unique.

I think you misunderstand my code. I don't know if im right but it seems you did not try my code or try understanding it. plz try it because I think its working. But I will explain it.
First I'm seperating each letters because I created each letter by divide and mod of character_count in which where I base of. ' It means i can base in character_count.
After I get the number of each letter I'm going to add the times of the product of exponent of the character_count^numberofletter

If you think your code is working then there is no point in my looking at it. If it isn't working then I have to know what you are trying to do in order to offer suggestions. The problem is that, based on your explanation, I do not have any idea what you are trying to do. How are we supposed to make sense statements like

in which where I base of. ' It means i can base in character_count.

I said its working but just a bit off i want to make it perfect or remove the "just a bit off". If you don't know what the meaning of the quote then my code can explain it.

in which where I base of. ' It means i can base in character_count.

Just like you said I dont know how to explain it well.
'In my code which make the integer to string
'No matter what input you put in the Integer of the Integer To String
'There is no way you can make a string like "a12b" (it's exact it doesnt output "a" as the first letter if the integer that you input is greater than the count of the characters)
I want to solve where even "a5" can be output by the Integer_To_String or (a as the first letter and the integer you input in the Integer_To_String is greater than the Characters_Count)

We are just going around in circles so I'll have to pass on this. Your code isn't doing what you want so reading your code to figure out what you want is pointless, and your explanation doesn't make any sense (to me) so reading the explanation doesn't help. Perhaps you can find a friend who is more fluent in English to provide a clearer explanation.

Ok. Im also thinking of that. Bye

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.