944,097 Members | Top Members by Rank

Ad:
May 23rd, 2007
0

numbering systems

Expand Post »
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
Similar Threads
Reputation Points: 11
Solved Threads: 2
Junior Poster in Training
w00dy is offline Offline
70 posts
since Jun 2005
May 23rd, 2007
0

Re: numbering systems

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)
Reputation Points: 12
Solved Threads: 2
Light Poster
SkinHead is offline Offline
31 posts
since May 2007
May 23rd, 2007
0

Re: numbering systems

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?
Reputation Points: 11
Solved Threads: 2
Junior Poster in Training
w00dy is offline Offline
70 posts
since Jun 2005
May 24th, 2007
0

Re: numbering systems

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.
Reputation Points: 26
Solved Threads: 5
Junior Poster
scudzilla is offline Offline
191 posts
since Mar 2007
May 24th, 2007
0

Re: numbering systems

What part do you not understand?
Reputation Points: 11
Solved Threads: 2
Junior Poster in Training
w00dy is offline Offline
70 posts
since Jun 2005
May 24th, 2007
0

Re: numbering systems

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 !
Reputation Points: 12
Solved Threads: 2
Light Poster
SkinHead is offline Offline
31 posts
since May 2007
May 24th, 2007
0

Re: numbering systems

I don't understand the
Quote ...
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.
Reputation Points: 26
Solved Threads: 5
Junior Poster
scudzilla is offline Offline
191 posts
since Mar 2007
May 24th, 2007
0

Re: numbering systems

Quote ...
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.
Reputation Points: 11
Solved Threads: 2
Junior Poster in Training
w00dy is offline Offline
70 posts
since Jun 2005
May 25th, 2007
0

Re: numbering systems

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

Vb Syntax (Toggle Plain Text)
  1. Public Function StringToHex(ByVal StrToHex As String) As String
  2. Dim strTemp As String
  3. Dim strReturn As String
  4. Dim I As Long
  5. For I = 1 To Len(StrToHex)
  6. strTemp = Hex$(Asc(Mid$(StrToHex, I, 1)))
  7. If Len(strTemp) = 1 Then strTemp = "0" & strTemp
  8. strReturn = strReturn & Space$(1) & strTemp
  9. Next I
  10. StringToHex = strReturn
  11. End Function

Here is the 'Hex To String' Function to convert it back
Vb Syntax (Toggle Plain Text)
  1. Public Function HexToString(ByVal HexToStr As String) As String
  2. Dim strTemp As String
  3. Dim strReturn As String
  4. Dim I As Long
  5. For I = 1 To Len(HexToStr) Step 3
  6. strTemp = Chr$(Val("&H" & Mid$(HexToStr, I, 2)))
  7. strReturn = strReturn & strTemp
  8. Next I
  9. HexToString = strReturn
  10. End Function
Reputation Points: 35
Solved Threads: 0
Light Poster
~Paul~ is offline Offline
31 posts
since May 2007
May 25th, 2007
0

Re: numbering systems

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 !
Reputation Points: 12
Solved Threads: 2
Light Poster
SkinHead is offline Offline
31 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Reading from non existant Text file
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: How to align array values





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC