Question allows inserting red text substrings in a userform textbox...

chazrab

Member
Joined
Nov 11, 2022
Messages
23
Programming Experience
10+
I have developed a BIble application in VBA; unfortunately the VBA environment does not allow inserting the words of Jesus in red text substrings in a userform textbox at specific start-end marker points. I was told that is easily done if the app were to be developed in C#. I'm, willing to spend the time(and $, if needed) to learn the C# ADE - if that can be done. Please help and comment or at least lead me on the right path. This is a big deal for me. Thank you in advance. cr
 
Last edited by a moderator:
What you were attempting in VBA is doable as long as you were doing VBA for Word.

Anyway with C#, it is also available, but you'll need to decide what your target platform will be. Will it be web based, an old fashioned desktop app, a modern Windows desktop app, a phone app? Based on the target platform, you'll have choices for what framework to use. Most frameworks will give you the ability to render text in different colors.
 
The default Windows textbox is monochrome. So if the textbox you were talking about in your original post was based on the default Windows textbox, then you plan on targeting the Windows desktop but continue to use the default Windows textbox, using another language is not going to help you.

You will have to use a UI control that allows coloring different runs of text with different colors/fonts. The Windows RichEdit control will let you do this. But that is for rendering. If you want the user to be able to switch colors while they are typing in, you'll need to provide UI controls for the user to be able to switch colors.
 
The default Windows textbox is monochrome. So if the textbox you were talking about in your original post was based on the default Windows textbox, then you plan on targeting the Windows desktop but continue to use the default Windows textbox, using another language is not going to help you.

You will have to use a UI control that allows coloring different runs of text with different colors/fonts. The Windows RichEdit control will let you do this. But that is for rendering. If you want the user to be able to switch colors while they are typing in, you'll need to provide UI controls for the user to be able to switch colors.
Hi Skydiver - and thanks for the very complete reply. This will be a modern Windows desktop application. Since I'm a newbie to C#, this probably will seem like a stupid question - but - your words "Based on the target platform, you'll have choices for what framework to use" - does that mean learning to code in C# in Visual Studio?

I played around with VS after watching some YT training vids - developing userforms to display text from various search results, displaying multiple translations, and resizing a textbox to be more readable are some components of my app - and this is all text based userform GUI's - just like any other BIble software app - and those things seem easy enough to replicate in C# - once I learn it.

- The problem VBA has - and this is Excel VBA - not Word VBA - is telling Excel when to begin red text and when to end it. I communicated with the original developer and author of Wordsearch that was developed in C# and he told me there are "markers" that tell the underlying code in C# when to begin and end red text. There are approximately 3,000+ words in the NT I need to do this for, whether by a formula or hard coding(which would be a pain). But many have done it - and so do I.

I sincerely apologize for the long reply back to you on this, Skydiver - but your reply got me excited. To me, from what little I've learned about VS, developing a userform with command buttons is not that different in VS using C# than it is in Excel VBA. It's just a matter of learning how and when to display red text substrings between those "markers" he was telling me about in VS - which with Excel VBA is a physical impossibility.

cr
Kingwood, Tx
 

Attachments

  • ONE E FORM VIEW. ALLOWS MULTIPLE SEARCHES SIMULTANEOUSLY.jpg
    ONE E FORM VIEW. ALLOWS MULTIPLE SEARCHES SIMULTANEOUSLY.jpg
    477.4 KB · Views: 9
For the Windows desktop, you have the choice of using WinForms (basically a thin wrapper around the old Windows Win32 API controls), WPF (Windows Presentation Framework), WinUI 3, or MAUI.

WinForms tends to have the easiest learning curve (and the most available online resources and tutorials), but it can also teach you some bad programming habits specially if you rely on old online resources written or produced on YouTube by some people so that they can pad their resumes. The other frameworks I mentioned above have in order decreasingly less available online resources and tutorials, but they in general will put you on a good learning path to build up great programming concepts and foundations. So you can choose to build your house on a rock or you can choose to build your house on sand, to borrow from a biblical story.
 
Anyway, you'll have two learning curves to climb: learning to code in C#, and learning to use your chosen framework. The best advice I can give is focus on learning C# first, then tackle learning a framework next. If you really want to try both at the same time, pick up a book that teaches both. Do not rely on YouTube and other videos. If you must do videos because of your learning style, prefer PluralSight. Avoid coding boot camps.
 
Back
Top Bottom