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 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)

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?

Er, no, I can't seem to understand your explanation. So far, there is Oct and Hex functions but for the others, I guess you have to convert manually. And, if you don't mind, please explain a little more.

What part do you not understand?

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 !

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.

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.

I guess the idea of that is instead of using string functions to find the different combinations in a sorting routine. Say the original string is "chain", then c =0, h = 1, a = 2, i =3, n =4.
So 03214 = ciahn, a valid anagram.
But 03213 has two 3's so is not valid.

Would converting the string to hex and then back to string be alright? If so here are two of my glorious functions ;)

``````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 ;)

``````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``````

This Is All Very Well, But You Haven't Said WHY You Want To Do This. If You Put It In Context, Then Maybe More Help Would Be Forthcoming.

Also, What About Words With Double/Triple Letters :

Food, Loot, Totty....Bookkeeping !

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.