| | |
numbering systems
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2005
Posts: 70
Reputation:
Solved Threads: 2
Is there a VB function to allow you to construct counters using different number systems ie base 3, base 4, base 5, 6, 7 etc ?
I haven't used VB for a while and I'm getting a headache trying to think how to get started on this, I just need pointing in the right direction, then I will be able to manage
Thanks for any help
I haven't used VB for a while and I'm getting a headache trying to think how to get started on this, I just need pointing in the right direction, then I will be able to manage
Thanks for any help
•
•
Join Date: May 2007
Posts: 31
Reputation:
Solved Threads: 2
I Don't Think There's A Built In Function Specifically To Change The Base.
The DIV & MOD Function May Help. Without Some Fancy Maths, Use These Functions To Create A String & Then Use The VAL Function.
To Add 1 To A Number In Base 6, You'd Have To Translate The Counter Into Base 10, Add1 Then Convert It Back Ito Base 6 (I Think)
The DIV & MOD Function May Help. Without Some Fancy Maths, Use These Functions To Create A String & Then Use The VAL Function.
To Add 1 To A Number In Base 6, You'd Have To Translate The Counter Into Base 10, Add1 Then Convert It Back Ito Base 6 (I Think)
•
•
Join Date: Jun 2005
Posts: 70
Reputation:
Solved Threads: 2
What I want to do is take a string and find all possible combinations of the characters in the string.
I read somewhere of one method that converts the characters to a number, using the number of characters to define the base ie if there are 5 characters then use base 5. Then as the counter counts up, select only those numbers that have no repeated digits ie 03214 would be selected but not 03213, then convert each selected number back to the corresponding characters.
Seems kind of roundabout to me and would prefer a more efficient way.
Does this explanation suggest anything?
I read somewhere of one method that converts the characters to a number, using the number of characters to define the base ie if there are 5 characters then use base 5. Then as the counter counts up, select only those numbers that have no repeated digits ie 03214 would be selected but not 03213, then convert each selected number back to the corresponding characters.
Seems kind of roundabout to me and would prefer a more efficient way.
Does this explanation suggest anything?
•
•
Join Date: May 2007
Posts: 31
Reputation:
Solved Threads: 2
OK, But What Is It You Want To Do ?
1. Count The Number Of Different Combinations....This Is A Straightforward Factorial Problem.
2. Enumerate (List) All The Different Combinations....This Would Be A Big Long Loop. The Problem Would Be Making It Reasonably Efficient.
3. Compare A Given String & See If There Is A Suitable Combination That Matches It.
I'm Not Sure Using A Different Number Base Will Help You, Although It May Be A Maths/Algorithmic Thing !
1. Count The Number Of Different Combinations....This Is A Straightforward Factorial Problem.
2. Enumerate (List) All The Different Combinations....This Would Be A Big Long Loop. The Problem Would Be Making It Reasonably Efficient.
3. Compare A Given String & See If There Is A Suitable Combination That Matches It.
I'm Not Sure Using A Different Number Base Will Help You, Although It May Be A Maths/Algorithmic Thing !
I don't understand the
•
•
•
•
as the counter counts up, select only those numbers that have no repeated digits ie 03214 would be selected but not 03213, then convert each selected number back to the corresponding characters.
There are 10 types of people: those who understand Binary and those who don't!
•
•
Join Date: Jun 2005
Posts: 70
Reputation:
Solved Threads: 2
•
•
•
•
as the counter counts up, select only those numbers that have no repeated digits ie 03214 would be selected but not 03213, then convert each selected number back to the corresponding characters.
So 03214 = ciahn, a valid anagram.
But 03213 has two 3's so is not valid.
•
•
Join Date: May 2007
Posts: 31
Reputation:
Solved Threads: 0
Would converting the string to hex and then back to string be alright? If so here are two of my glorious functions 
Here is the 'Hex To String' Function to convert it back

Vb Syntax (Toggle Plain Text)
Public Function StringToHex(ByVal StrToHex As String) As String Dim strTemp As String Dim strReturn As String Dim I As Long For I = 1 To Len(StrToHex) strTemp = Hex$(Asc(Mid$(StrToHex, I, 1))) If Len(strTemp) = 1 Then strTemp = "0" & strTemp strReturn = strReturn & Space$(1) & strTemp Next I StringToHex = strReturn End Function
Here is the 'Hex To String' Function to convert it back

Vb Syntax (Toggle Plain Text)
Public Function HexToString(ByVal HexToStr As String) As String Dim strTemp As String Dim strReturn As String Dim I As Long For I = 1 To Len(HexToStr) Step 3 strTemp = Chr$(Val("&H" & Mid$(HexToStr, I, 2))) strReturn = strReturn & strTemp Next I HexToString = strReturn End Function
![]() |
Similar Threads
- counting lesson(for the slow among us) (Posting Games)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Reading from non existant Text file
- Next Thread: How to align array values
Views: 1887 | Replies: 9
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





