numbering systems

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

numbering systems

 
0
  #1
May 23rd, 2007
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
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 31
Reputation: SkinHead is an unknown quantity at this point 
Solved Threads: 2
SkinHead SkinHead is offline Offline
Light Poster

Re: numbering systems

 
0
  #2
May 23rd, 2007
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)
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: numbering systems

 
0
  #3
May 23rd, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 181
Reputation: scudzilla is an unknown quantity at this point 
Solved Threads: 3
scudzilla's Avatar
scudzilla scudzilla is offline Offline
Junior Poster

Re: numbering systems

 
0
  #4
May 24th, 2007
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.
There are 10 types of people: those who understand Binary and those who don't!
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: numbering systems

 
0
  #5
May 24th, 2007
What part do you not understand?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 31
Reputation: SkinHead is an unknown quantity at this point 
Solved Threads: 2
SkinHead SkinHead is offline Offline
Light Poster

Re: numbering systems

 
0
  #6
May 24th, 2007
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 !
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 181
Reputation: scudzilla is an unknown quantity at this point 
Solved Threads: 3
scudzilla's Avatar
scudzilla scudzilla is offline Offline
Junior Poster

Re: numbering systems

 
0
  #7
May 24th, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: numbering systems

 
0
  #8
May 24th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 31
Reputation: ~Paul~ is an unknown quantity at this point 
Solved Threads: 0
~Paul~ ~Paul~ is offline Offline
Light Poster

Re: numbering systems

 
0
  #9
May 25th, 2007
Would converting the string to hex and then back to string be alright? If so here are two of my glorious functions

  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
  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
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 31
Reputation: SkinHead is an unknown quantity at this point 
Solved Threads: 2
SkinHead SkinHead is offline Offline
Light Poster

Re: numbering systems

 
0
  #10
May 25th, 2007
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 !
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 1887 | Replies: 9
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC