two questions regarding my custom made book writing program

  • (2 Pages)
  • +
  • 1
  • 2

25 Replies - 776 Views - Last Post: 11 January 2012 - 02:56 PM Rate Topic: -----

#1 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 255
  • Joined: 21-May 09

two questions regarding my custom made book writing program

Posted 02 January 2012 - 05:44 PM

hi its me again :P
some of you may remember that i made text editor program designed for book writing (look for a topic named "Blank line at end of textfile" to refresh your memory if needed :P)

so it all work *almost* great and i'm finding new ways to improve it and that lead me to my first question:

1) i was thinking about adding a system that hold a list of words for easy writing.
so insted of having to write certian words that repeat themselves many times i could just click a button and add them.
such system is easy: just a file holding the word list,code to load it into listbox and a button with code for checking what word was selected and add it into the textbox where the rest of the text is.
however what if i want to insert a word in the middle of the text? just marking the area where i'd want to insert wont work sice the correct code will add the word in the end of the text.
so is there a way to let the program know where i want to insert it?

the correct idea for code i have is this:
Private sub button_Click()
'code for checking what word was selected
'word selected placed inside string variable lets say TmpWord
text1.text = text1.text & TmpWord
end sub




now to my other question:
i noticed that when holding the backspace button the program start deleting more text then what i want and that force me to tap on the button.
i think the problem might be here but i'm not so sure:

Private Sub counter()
num_words = 0

in_word = False

For I = 1 To Len(Text1.Text)
ch = Mid$(Text1.Text, I, 1)
Select Case ch
Case " ", vbTab, vbCr, vbLf
in_word = False
Case Else
If Not in_word Then
in_word = True
num_words = num_words + 1
End If
End Select
Next I

Label1.Caption = num_words
If num_words < MaxWords Then
Label1.ForeColor = vbBlack
Call unblocker
Err = False
ElseIf num_words >= MaxWords Then
Call blocker(num_words)
Label1.ForeColor = vbRed
Err = True
End If
End Sub



this code count how many words there are inside the textbox.
i cant debug in IDE because i'm kinda lazy to change all the reference to the INI file to be on specifice location and then having to change again before compiling :P (without INI file program wont run) (and honestly while debugging other problems on older versions with IDE i never got this problem, only after compiling).

some light will be nice :)

Is This A Good Question/Topic? 0
  • +

Replies To: two questions regarding my custom made book writing program

#2 tlhIn`toq  Icon User is offline

  • Closing in on 5,000
  • member icon

Reputation: 4926
  • View blog
  • Posts: 10,461
  • Joined: 02-June 10

Re: two questions regarding my custom made book writing program

Posted 03 January 2012 - 08:11 AM

Being someone who enjoys costuming and halloween in general I was all excited when I read the title of this post.

Imagine my disappointment when I realized you meant 'custom' not 'costume'. :(

I just have to point out the irony of writing a program for the development of books, when your writing is horrible. Massive number of misspelled words, virtually no capitalization, run on sentences [...]

Quote

so insted of having to write certian words that repeat themselves many times i could just click a button and add them.


Do you really think there is a big need for this? I can't imagine how this would help anyone. It would take at least 10 times longer to move your hand from the keyboard to the mouse, scroll through a list, find the word, choose it, then return your hand to the keyboard and make sure its on the home row so you can continue typing. All for what? To avoid typing the word "together"... "capitalism". Personally I think its a silly thing that users won't use.

This post has been edited by tlhIn`toq: 03 January 2012 - 08:12 AM

Was This Post Helpful? 0
  • +
  • -

#3 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 255
  • Joined: 21-May 09

Re: two questions regarding my custom made book writing program

Posted 03 January 2012 - 01:21 PM

1)sorry for misspelling costum with costume
2)sorry for not starting each sentece with capital letter here in the forum, but dont worry about this since in the book i write i do start each sentence with capital letter and write "I" insted of "i".
3)and sorry for other misspells i might have.
but all of the above are not the real problems.
the real problems are with the program itself: the problem that holding the backspace for deleting text cause the program to delete more then it should and the problem on how to make the program insert a selected word anywhere i want insted of only in the end of a sentence.

as for problem number 2: true most people find it easier to just type a word rather than looking for it in a list and clicking on a button.
but so is the small system i placed for seeing the last 10 files that were used.
some people might prefer to just click File->open and look for the file insted of looking for in a list, some will prefer the other way.
this word list system i want to implant can have other uses too: like search and replace system so i could replace one word with another.
for that i'll need the two words and the location of the word i want to replace.
therefor this system is usefull and people will use it :)
some help on these problem will be nice :)
Was This Post Helpful? 0
  • +
  • -

#4 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 123
  • Joined: 02-January 12

Re: two questions regarding my custom made book writing program

Posted 03 January 2012 - 04:27 PM

Regarding your problem with replacing a selected word with another word this should work:

Dim txttoReplace As String
Dim newtext As String

'get highlighted text
txttoReplace = Text1.SelText

'get new word from list of words
newtext = List1.Text

'replace selected word from text box with word from a list
Text1.Text = Replace(Text1.Text, txttoReplace, newtext)



Considering English is probably your second language you're doing OK
Was This Post Helpful? 1
  • +
  • -

#5 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 255
  • Joined: 21-May 09

Re: two questions regarding my custom made book writing program

Posted 04 January 2012 - 09:59 AM

great this code work just great :D
thank you very much for it :)
yes my native language is hebrow, my second english and my third is italian :3
also i study russian at work (exept of me everyone else are russian so i have too :P) and i study japanese too ;)

now lets see if i (or most likely we) can solve the second problem :D
Was This Post Helpful? 0
  • +
  • -

#6 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 123
  • Joined: 02-January 12

Re: two questions regarding my custom made book writing program

Posted 04 January 2012 - 01:19 PM

Can I assume that Private Sub Counter is called after every keystroke?
Was This Post Helpful? 0
  • +
  • -

#7 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 255
  • Joined: 21-May 09

Re: two questions regarding my custom made book writing program

Posted 04 January 2012 - 01:22 PM

yes it does being called with every kaystroke

This post has been edited by Neku: 05 January 2012 - 08:47 AM

Was This Post Helpful? 0
  • +
  • -

#8 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 255
  • Joined: 21-May 09

Re: two questions regarding my custom made book writing program

Posted 04 January 2012 - 01:28 PM

i think i got the idea ><
use it with timer?
Was This Post Helpful? 0
  • +
  • -

#9 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 123
  • Joined: 02-January 12

Re: two questions regarding my custom made book writing program

Posted 04 January 2012 - 01:39 PM

I tried your code out "as is" and the backspace key didn't do anything out of the ordinary??
It seems ok to me.
Was This Post Helpful? 0
  • +
  • -

#10 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 33
  • View blog
  • Posts: 380
  • Joined: 26-October 09

Re: two questions regarding my custom made book writing program

Posted 04 January 2012 - 05:10 PM

A point of note that List1.text althoug it will work a better way to code this would be to use the listindex and the list property as it can be done via the list item that is selected. For instance:

NewTXT = list1.list(list1.listindex))



you can do much with that line of code. but I feel that you would be best to use it in place of the list1.text. for reasons that it would be confusing to someone and syntax it is correct for the list box.

Just my Honest Opinion.
Jesse Fender
Was This Post Helpful? 1
  • +
  • -

#11 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 255
  • Joined: 21-May 09

Re: two questions regarding my custom made book writing program

Posted 05 January 2012 - 08:30 AM

the problem with the backspace key happened after i compile the program and when the textbox have some 500 words in it.
when trying to delete text by holding backspace it may get stuck and delete more then what i want.
as for post #10: thank you :) i will try this
Was This Post Helpful? 0
  • +
  • -

#12 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 123
  • Joined: 02-January 12

Re: two questions regarding my custom made book writing program

Posted 05 January 2012 - 01:28 PM

If you are calling the Counter Procedure from the Text Box's Key_Down or Key_Press event then shift this to the Key_Up event and this should solve your problem.
Was This Post Helpful? 1
  • +
  • -

#13 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 255
  • Joined: 21-May 09

Re: two questions regarding my custom made book writing program

Posted 05 January 2012 - 05:11 PM

its being called from the change event
Was This Post Helpful? 0
  • +
  • -

#14 deanobravo  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 123
  • Joined: 02-January 12

Re: two questions regarding my custom made book writing program

Posted 05 January 2012 - 05:21 PM

change will cause the same problem, the more text you have the worse backspace will behave, try key_up
Was This Post Helpful? 1
  • +
  • -

#15 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 255
  • Joined: 21-May 09

Re: two questions regarding my custom made book writing program

Posted 07 January 2012 - 01:41 PM

thank you :) I'v tried this and seems that the problem is solved but i have now another tiny problem xD

that's the code that count word:
Private Sub counter()
num_words = 0

in_word = False

For I = 1 To Len(Text1.Text)
ch = Mid$(Text1.Text, I, 1)
Select Case ch
     Case " ", vbTab, vbCr, vbLf, "!", "@", "#", "$", _
     "%", "^", "&", "*", "(", ")", "[", "]", "{", "}", _
     ".", "?", "<", ">", ",", "/", "\", "|", "~", "`", _
     "'", "-", "_", "=", "+", ":", ";"
     in_word = False
Case Else
If Not in_word Then
     in_word = True
     num_words = num_words + 1
End If
End Select
Next I

Label1.Caption = num_words
If num_words < MaxWords Then
     Label1.ForeColor = vbBlack
     Call unblocker
     Err = False
ElseIf num_words >= MaxWords Then
     Call blocker(num_words)
     Label1.ForeColor = vbRed
     Err = True
End If
End Sub



the problem is in the select case: i cant add this character to the list "
so how i can fix it? should i just ignore this one or should i get its ASCII value and add it to the select case?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2