I'm making a Notetaking program that makes it faster for writing notes on the computer. It will add Roman Numerals and Upper Case Letters, Lower Case, ect.
However, my problem is when I put say three roman numerals into the textbox
I.
II.
III.
And I erase all three, and put anothe roman numeral in, it will put roman numeral four in (IV) How could I make it so it checks to see what roman numeral is in the textbox and then enters the next one up?
So if I have I. II. III. in the textbox and erase II. and III. it will enter a II.
Sorry if you have a hard time understand this
I have also attached my project so you can maybe take a look at it
thanks for the code rhino, but I still havn't figured out a way to search the textbox and figure out what roman numerals are in the textbox, so then the next roman numeral that is added is in coordination with the rest already entered.
Re: Changing text in textbox once something is erased
Originally Posted by paralinx
It's not letting you open the project?
I swear the 1st time I tried to open the project it wanted a password for the vbp file and when I didn't supply one it deleted the vbp file! Very strange. In any case I downloaded it again and the only thing I can suggest is that instead of generating the roman numerals that you create a type like this
VB Code:
Private Type RomanNumerals
rnRoman As String
rnUsed As Boolean
End Type
Private Romans(99) As RomanNumerals
and then load it with the 1st hundred(?) roman numerals setting all the rnUsed flags to False. Then of course you can examine the array for the first one that's not used and when deleting one from your note you would set the associated array member to False.
Re: Changing text in textbox once something is erased
Good idea Martin, thanks. But how could I figure out what roman numerals were erased if the textbox has something like this in it..
Code:
I. Blah blah blah blah
A. blah blah blah blah
B. blah
-blah blah
-blah bleh?
II. Bleh blah blah
A. Blah
III. Hey more blah
a. you want some more blah?
b. because I sure do
It would be hard to tell when a roman numeral was taken out. Unless there was some way I could search for all roman numerals
Re: Changing text in textbox once something is erased
You'd need to scan your text constantly - timer comes to mind first...
If "I" is found then search for "II" and so on ... InStr() may work but the problem is that you may have refences somewhere in the paragraph (say VI) to another paragraph (some like "...see par IV for more info ...) and that could still be there. So, InStr will return true and indexing will be out of bounds.
Re: Changing text in textbox once something is erased
Is it also true that there will never be any text to the left of the roman numeral? If so then that's a test you could use to determine what's there. That would also help you avoid things like "My favorite king is George V."
Re: Changing text in textbox once something is erased
There can be text before the roman numerals.
I tried searching for the roman numerals your way rhino but it does not work. It will get to roman numeral two and continue putting in Roman Numeral twos.
Heres my code
VB Code:
Dim sRev As String, sRom As String, sArr() As String
Dim iNext As Integer, i As Integer, RomanAmt As Integer
Re: Changing text in textbox once something is erased
Using RB's idea as a springboard:
Depending how high the roman numerals are going to get, you might want to adopt some sort of 'intelligent' (playing fast and loose with that word) searching:
Say they've gone up to LIII. That would be 53 InStr() calls if you go I., II., III., etc.
An alternative would be look in intervals and then narrow it:
Code:
Look for: XX - Present +20
XL - Present +20
LX - Not Present -10
L - Present +5
LV - Not Present -3
LII - Present +1
LIII - Present +1
LIV - Not Present - Highest is LIII
Obviously an optimum algorithm for your senario would take some experimentation.
Re: Changing text in textbox once something is erased
I'm afraid it wouldn't be as simple:
say you typed I,II,III ... X and so on. But then you say "hmmm... IV and V really belong to III" so you erased them both but in your textbox there are VI,VII and so on.
So, what are you going to set as you next available index? IV? That was my initial concern - you'll get your index out of bounds... (well sorta).
Honestly, I don't have any more or less reasonable idea at the moment so it will take some experimenting to figure it out how to handle this stuff.
Remember to declare DeletedText as string at the top of your code
This will remember everything you delete, and check for roman numerals at the start of the text. Deleting a period will reset the remembered text, to notify the program that a possible roman numeral is starting.
I tested it, but not much, so there may be a few bugs to clear up.
Hope this gets you on the right track =)
-Rob
Last edited by Rob123; Mar 20th, 2006 at 03:09 AM.
Re: Changing text in textbox once something is erased
Observations:
I thought that if you deleted a line and it's roman that the next time you added a roman it would replece the number you deleted but it doesn't seem to do that.
It would be nice I think if upon pressing Enter that the next roman numeral would be generated automatically.
Shouldn't the next roman after pressing F7 be "I"?
You don't have a function key for "Indent" and you don't have a button for "Clear"