Working with Code in e-Books

Most of my technical readers now use e-books instead of paper books. Of course, there is a convenience factor to storing your entire library on a Kindle, even if it’s a software version of the Kindle. Of course, there are all sorts of e-book formats for your desktop system as well. The point is that electronic format makes a lot of sense when dealing with technical books.

However, e-books can cause some interesting problems and I’ve encountered a few with a number of readers now. The most important consideration is that you can’t cut and paste code from an e-book directly into your IDE and expect it to work. There are all sorts of reasons for this exclusion. For example, cutting and pasting may insert special characters into the output stream or the resulting paste may not have white space in the right places. A common problem is that publishers often convert regular single and double quotes into curly quote equivalents. The two kinds of quotes (both single and double) are completely different and the second type definitely won’t compile.

The best option when working with an e-book is to view the code in the e-book, but still get the downloadable source code for the book from the publishers website. I always provide a blog post detailing where to obtain the downloadable source for a book, when you need source code to use the book. If you can’t find the downloadable source, always feel free to contact me at John@JohnMuellerBooks.com. I want to be sure you have a great reading experience, which means having source code that actually runs in your development environment.

Another potential problem with e-books is that you may see unfortunate code breaks (despite the efforts of the publisher and myself). When you need to understand how white space works with a programming language, always review the downloadable source. The fact that the downloadable source compiles and runs tells you that all the of white space is in the right place and of the correct type. Typing the source code directly out of your e-book could result in added carriage returns or other white space errors that will cause the code to fail, even though the commands, variables, and other parts of the code are all correct.

As always, I’m open to your questions about my books. If you don’t understand how things work, please contact me—that’s why I’m here.

 

Source Code Placement

I always recommend that you download the source code for my books. The Verifying Your Hand Typed Code post discusses some of the issues that readers encounter when typing code by hand. However, I also understand that many people learn best when they type the code by hand and that’s the point of getting my books—to learn something really interesting (see my principles for creating book source code in the Handling Source Code in Books post). Even if you do need to type the source code in order to learn, having the downloadable source code handy will help you locate errors in your code with greater ease. I won’t usually have time to debug your hand typed code for you.

Depending on your platform, you might encounter a situation the IDE chooses an unfortunate place to put the source code you want to save. For example, on a Windows system it might choose the C:\Program Files folder (or a subdirectory) to the store the file. Microsoft wants to make your computing experience safer, so you don’t actually have rights to this folder for storing your data file. As a result, the IDE will stubbornly refuse the save the files in that folder. Likewise, some IDEs have a problem with folder names that have spaces in them. For example, your C:\Users\<Your Name>\My Documents folder might seem like the perfect place to store your source code files, but the spaces in the path will cause problems for the IDE and it will claim that it can’t find the file, even if it manages to successfully save the file.

My recommendation for fixing these, and other source code placement problems, is to create a folder that you can access and have full rights to work with to store your source code. My books usually make a recommendation for the source code file path, but you can use any path you want. The point is to create a path that’s:

  • Easy to access
  • Allows full rights
  • Lacks spaces in any of the path name elements

As long as you follow these rules, you likely won’t experience problems with your choice of source code location. If you do experience source code placement problems when working with my books, please be sure to let me know at John@JohnMuellerBooks.com.

 

Review of Mastering VBA

A lot of people have asked about the next book to read after reading VBA for Dummies. Yes, the current 5th edition of VBA for Dummies still works fine as a starting point, even with issues such as dealing with the Ribbon to consider. In fact, you can find some great updates to VBA for Dummies on my blog. However, the fact of the matter is that readers have been asking for more, which is where Mastering VBA by Richard Mansfield comes into play. This is the next book you should get if you want to move on from what VBA for Dummies shows you to writing applications with greater functionality. For example, a lot of you have requested more information about creating forms and Chapters 13 through 15 will help you in this regard. Richard has done an outstanding job of moving you to the next step of creating the complex forms required for robust applications.

Another common request that Mastering VBA addresses is the need for security. While VBA for Dummies helps you understand the need for basic security, Mastering VBA takes the process several steps further and could help prevent breaches given the modern computing environment (one that didn’t exist when I wrote VBA for Dummies). Chapter 18 begins the process by emphasizing the need to build well-behaved code. After all, if your code doesn’t behave, there isn’t any set of security measures that will protect it from harm. Chapter 19 goes on to help you understand the essentials of good security, especially with all the modern threats that cause problems for developers today.

At 924 pages (versus 412 for VBA for Dummies), Richard is also able cover some topics in detail that would have been nice to have in my own book. Readers have complained about having to go online to view object model details for the various Office applications in my book. Mastering VBA provides coverage of the object model as part of the book so you can work through it without having to go anywhere else. It’s a convenience issue—readers really shouldn’t have to look for essentials like the object model online, but every author has to face space limitations when putting a book together. The object model material is spread out across the book, but there really isn’t any way to organize it so that it all appears together. This is one time when you’ll need to actually use the table of contents and index to find the material you need.

As with all the books in the Mastering series, this one has questions at the end of each chapter. These questions are designed to help you master the skills learned in the chapter. You find the answers for each of the questions in the back of the book. This makes Mastering VBA an excellent option for the classroom. More importantly, it gives you another way to learn the material in the book. The longer I write books, the more I come to realize that one or two methods of learning simply won’t do the job. This book usually provides three or four ways to learn each task, which means that you have a higher probability of actually mastering the material (as defined by the title).

For all of you who have been asking for the next book after VBA for Dummies, Mastering VBA is the one that gets my recommendation. Until I actually have time to write a book that specifically addresses the concerns in the reader e-mails I’ve received, this book is your best option. No, it doesn’t address every e-mail request that I’ve received, especially with regard to form creation, but it does answer a considerable number of them. Of course, I’ll look forward to your continued interest in my book and I hope you keep those e-mails coming my way!

 

Using My Coding Books Effectively

A lot of people ask me how to use my books to learn a coding technique quickly.  I recently wrote two articles for New Relic that help explain the techniques for choosing a technical book and the best way to get precisely the book you want. These articles are important to you, the reader, because I want to be sure that you’ll always like the books you purchase, no matter who wrote them. More importantly, these articles help you get a good start with my coding books because you start with a book that contains something you really do need.

Of course, there is more to the process than simply getting the right book. When you already have some experience with the language and techniques for using it, you can simply look up the appropriate example in the book and use it as a learning aid. However, the vast majority of the people asking this question have absolutely no experience with the language or the techniques for using it. Some people have never written an application or worked with code at all. In this case, there really aren’t any shortcuts. Learning something really does mean spending the time to take the small steps required to obtain the skills required. Someday, there may be a technology that will simply pour the knowledge into your head, but that technology doesn’t exist today.

Even reading a book cover-to-cover won’t help you succeed. My own personal experiences tell me that I need to use multiple strategies to ensure I actually understand a new programming technique and I’ve been doing this for a long time (well over 30 years). Just reading my books won’t make you a coder, you must work harder than that. Here is a quick overview of some techniques that I use when I need to discover a new way of working with code or to learn an entirely new technology (the articles will provide you with more detail):

  • Read the text carefully.
  • Work through the examples in the book.
  • Download the code examples and run them in the IDE.
  • Write the code examples by hand and execute them.
  • Work through the examples line-by-line using the debugger (see Debugging as An Educational Tool).
  • Talk to the author of the book about specific examples.
  • Modify the examples to obtain different effects or to expand them in specific ways.
  • Use the coding technique in an existing application.
  • Talk to other developers about the coding technique.
  • Research different versions of the coding technique online.
  • View a video of someone using the technique to perform specific tasks.

There are other methods you can use to work with my books, but this list represents the most common techniques I use. Yes, it’s a relatively long list and they all require some amount of effort on my part to perform. It isn’t possible to learn a new technique without putting in the time required to learn it. In a day of instant gratification, knowledge still requires time to obtain. The wisdom to use the knowledge appropriately, takes even longer. I truly wish there were an easier way to help you get the knowledge needed, but there simply isn’t.

Of course, I’m always here to help you with my books. When you have a book-specific question, I want to hear about it because I want you to have the best possible experience using my books. In addition, unless you tell me that something isn’t working for you, I’ll never know and I won’t be able to discuss solutions for the issue as part of blog post or e-mail resolution.

What methods do you use to make the knowledge you obtain from books work better? The question of how people learn takes up a considerable part of my time, so this is an important question for my future books and making them better. Let me know your thoughts about the question at John@JohnMuellerBooks.com. The same e-mail address also works for your book-specific questions.

 

VBA Examples Online

When I originally wrote VBA for Dummies, I included a number of links to third party resources. Of course, a few of those links are no longer active. I was really happy to hear from JoJo Zawawi the other day about the link to his excellent VBA examples. The link found in my book, http://www.jojo-zawawi.com/code-samples-pages/code-samples.htm, is no longer active. You need to use http://www.thezcorp.com/VBACodeSamples.aspx instead.

If you ever find a broken link in one of my books, please be sure to let me know about it. I’ll be more than happy to provide an updated link here so everyone can continue to use the resource. Please contact me about your link concerns at John@JohnMuellerBooks.com.

 

Examining the Calculator in Windows 7 (Part 2)

A while back, over two years ago in fact, I uploaded a post entitled, “Examining the Calculator in Windows 7.” Since that time, a number of people have asked about the other features that the new calculator includes. Yes, there are these rather significant problems that Microsoft has introduced, but there are some good things about the new calculator as well.

The good thing appears on the View menu. When you click this menu, you see options at the bottom of the list that provide access to the special features as shown here.

The View menu includes options for unit conversion, date conversion, and worksheets.
The Windows 7 Calculator View Menu

The Unit Conversion and Date Conversion options are the most useful. However, the worksheets can prove helpful when you need them. Of the new features, I personally use Unit Conversion the most and many people likely will. After all, it’s not often you need to figure out a new mortgage, vehicle lease amount, or the fuel economy of your vehicle (and if you do such work for a living, you’ll have something better than the Windows Calculator to use). To see what this option provides, click Unit Conversion. You see a new interface like the one shown here:

The Unit Conversion display makes it possible to convert from one unit of measure to another.
Calculator Unit Conversion Display

You start using this feature by selecting the type of unit you want to convert. As you can see from this list, the kinds of conversions you can perform are extensive:

Select a conversion type to determine what options are offered in the From and To fields.
The Calculator Supports a Healthy List of Conversion Types

The option you select determines the content of the From and To fields. For example, if you want to convert from kilometers to miles, you select the Length option. After you select the type of unit, type a value in the From field and select the From field unit of measure. Select the To field unit of measure last. Here is what happens when you convert 15 kilometers to miles:

The output shows that converting 15 kilometers to miles equals 9.32056788356001 miles.
Converting Kilometers to Miles

I’ve found use for most of the entries in the types list at one time or another. Every one of them works quite well and you’ll be happy they’re available when you need them. The Data Calculation option can be similarly useful if you work with dates relatively often, as I do. However, I can’t see many people needing to figure out the number of days between two dates on a regular basic. Even so, this feature is probably used more often than any of the worksheets.

The ability to perform conversions of various kinds and to access the worksheets that Windows 7 Calculator provides isn’t enough to change my opinion. The implementation of the Calculator is extremely flawed and I stick by my review in the first posting. However, you do have the right to know there are some positives, which is the point of this post. Let me know your thoughts about Calculator now that you have a better view of it at John@JohnMuellerBooks.com.

 

VBA Book Needs and Wants

A lot of people still buy VBA for Dummies even though this book has gotten a little long in the tooth. The reason is simple, the book still works fine because Microsoft has put little effort into making VBA a better language. Even though the idea was that people would move to Visual Studio to create Microsoft Office add-ons, the fact is that most of the people using VBA have no desire whatsoever to make the move. In addition, there is a huge base of VBA resources available and no business in its right mind would ever stop using them as long as they get the job done. So, the fact of the matter is that VBA for Dummies will continue to be a great book for your shelf.

However, I also realize the book has shortcomings. It goes too far in some directions and not nearly far enough in others. The blog posts for this book point out a number of these flaws and provide fixes for them. In addition, people have been asking for a “next book” for quite some time now. With this in mind, I’m currently working on ideas for that next book, the one that you want to put right beside VBA for Dummies on your shelf to get a fuller picture of what VBA can do for you and to act as a resource when you need it.

So far I have collected well over 1,200 reader e-mails for this book. Certainly, I have enough ideas to start another book. However, I do want to hear from you. What sorts of things do you consider essential for that next book? Some readers have suggested that I open my book up to products other than Microsoft Office. There are a number of them out there that do use VBA (or something close enough that knowing VBA helps quite a lot). Other readers have requested better information about forms and still others want to see a full-fledged application of some sort. Many of the e-mails I receive talk about interoperability between Office products. In short, there are a lot of potential areas that you could tell me you need, but perhaps you have some unique need that I should consider.

VBA for Dummies is a great book that continues to sell well and I want to support your coding efforts in every way that I can. What I need are ideas that would generally appeal to everyone. Don’t send me a request to provide what amounts to free consulting for your specific application. A request to provide better support for forms that help format content is a valid request; a request to demonstrate access connection techniques for your company’s local intranet won’t work at all. Contact me with your ideas for that next book at John@JohnMuellerBooks.com.

As always, thank you for the incredible level of support you have provided me over the years. I continue to be amazed at some of the e-mails I receive. These ideas would be just another example of your desire to have high quality technical books on your shelves.

 

Coding Schools and the Learning Process

There are three essential ways to begin a career as a developer. The first is to get a college degree in the subject, which is normally a Bachelor of Computer Science or a Bachelor of Information Technology (amongst other degrees). The second is to teach yourself the trade, which means spending a lot of time with books and in front of your screen working through online tutorials. The third is a new option, coding school. The third option has become extremely popular due to limitations in the first two techniques.

The cost of a college education has continued to skyrocket over the past few decades until it has started to elude the grasp of more than a few people. I’ve read estimates that a college degree now costs between $20,000 and $100,000 in various places. How much you actually pay depends on the school, your personal needs, and the electives you choose. The point is that many people are looking for something less expensive.

A college education also requires a large investment in time. A four year degree may require five or six years to actually complete because most people have to work while they’re going to school. A degree is only four years when you can go full time and apply yourself fully. Someone who is out of work today and needs a job immediately can’t wait for five or six years to get a job.

Teaching yourself is a time-honored method of obtaining new skills. I’ve personally taught myself a considerable number of skills. However, I’m also not trying to market those skills to someone else. My self-taught skills usually come in the areas of crafting or self-sufficiency (or sometimes a new programming language). The problem with being self-taught is that you have no independent assessment of your skills and most employers can’t take time to test them. An employer needs someone with a proven set of skills. Consequently, self-teaching is extremely useful for learning new hobbies or adding to existing (proven) skills, but almost valueless when getting a new job. In addition, few people are actually motivated enough to learn a new skill completely (at the same level as a college graduate) on their own.

Coding schools overcome the problem with self-teaching because they offer proof of your skills and ensure you get a consistent level of training. You get the required sheepskin to show to employers. They also address deficiencies in the college approach. The time factor is favorable because most of these schools promise to teach you basic development skills in three months (compared to the five or six years required by a college). In addition, the cost is significantly less (between $6,000 and $18,000). So, it would seem that going to a coding school is the optimum choice.

Recently people have begun to question the ability of coding schools to fulfill the promises they make. It’s important to consider what a coding school is offering before you go to one. The schools vary greatly in what they offer (you can see reviews of three popular code schools at http://www.mikelapeter.com/code-school-vs-treehouse-vs-codecademy-a-review/). However, there are similarities between schools. A coding school teaches you the bare basics of a language. You don’t gain the sort of experience that a college graduate would have. In addition, coding schools don’t teach such concepts as application design or how to work in a team environment. You don’t learn the low-level concepts of how application development works. I don’t know if building a compiler is still part of the curriculum at colleges, but it was one of my more important learning experiences because I gained insights into how my code actually ended up turning switches on and off within the chips housed in the computer.

I see coding schools as fulfilling an important role—helping those who do have programming skills to build competence in a new language quickly. In addition, a coding school could provide an entry point for someone who thinks they may want a computer science degree, but isn’t certain. Spending a short time in a coding school is better than spending a year or two in college and only then finding out that computer science isn’t what the person wants. Coding schools could also help people who need to know how to write simple applications as part of another occupation. For example, a researcher could learn the basic skills require to write simple applications to aid in their main occupation.

People learn in different ways. It’s the lesson that readers keep driving home to me. Some people learn with hands on exercises, some by reading, and still others by researching on their own. Coding schools can fulfill an important role in teaching computer science, but they’re not even close to a complete solution. In order to get the full story about computer science, a student must be willing to invest the required time. Until we discover some method for simply pouring information into the minds of people, the time-consuming approach to learning must continue as it has for thousands of year. There really aren’t any shortcuts when it comes to learning. Let me know your thoughts about coding schools at John@JohnMuellerBooks.com.

 

VBA’s Long Lasting Viability

Microsoft has taken great pains over the years to try to kill VBA off. I’ve discussed some of the issues surrounding this effort in two previous posts: VBA and Office 2013 and VBA and Office 2013 (Part 2). Because of these efforts, a number of people have written to ask me about VBA and my book about it. The fact of the matter is that most of the examples in VBA for Dummies continue to work fine and VBA remains a viable development platform for applications. Microsoft’s efforts to move VBA developers to Visual Studio Tools for Office (VSTO) haven’t been as successful as Microsoft would like—mostly because most VBA developers have other careers and don’t want to learn how to use VSTO.

I do continue to provide updates for my book in the VBA for Dummies category of this blog. The latest such post discusses trigonometric calculations in VBA. As you find book issues, I’ll continue to address them in this blog. In addition, as time permits, I’ll discuss VBA issues in general and provide additional examples that relate to the content in my book. All I really need is your input at John@JohnMuellerBooks.com to know what sorts of content you’d like to see. Your e-mails help me decide which issues are most important to you, so please do write when you see a particular need.

Of course, the biggest question about VBA is the one I haven’t answered yet. Some people have wondered whether VBA is still a viable language for new development. The fact that even Microsoft has provided updated macros for VBA should tell you something. If there were no interest in new development, you can be sure that Microsoft wouldn’t waste time in posting macros for Office 2013. In fact, a Google search shows 122,000 hits for sites that have updated their VBA information in the last year. That’s a lot of interest in a language that Microsoft has tried so hard to kill off.

I still see VBA as the language to use when you have any sort of Office automation need—VSTO is a better choice when you actually want to extend Office functionality or define new behaviors (work that full-fledged developers normally perform). It’s incredibly easy to use and most people can learn to use the basic features quite quickly. In fact, because it’s interpreted, VBA makes a great way for people to start learning basic programming principles.

The only caveat for today is to ensure that your code doesn’t have any compatibility issues, especially if you plan to use your VBA macros with Office 365. There is a lot of old code out there that might not work with newer versions of Office. With this in mind, Microsoft has created the Office Code Compatibility Inspector (OCCI). Make sure you download as use this tool to check your code.

 

Using the Trigonometric Functions in VBA

It’s gratifying to know that people are still buying and using VBA for Dummies to perform useful work. I still get a fair number of reader queries about the book and I’ve tried to provide updates to keep the book useful as part of my blog. So, I was appalled recently to find that there is an error in one of the examples. The error appears in both the 4th edition of the book (on page 83) and in the 5th edition book (on page 99). It affects the use of trigonometric functions to perform various kinds of calculations involving angles.

Most of us are used to thinking about angles in degrees. However, most mathematicians use radians, not degrees, when working with angular measurements. The main reason for using radians is that degrees measure direction, rather than the angular part of a circle (there is actually some discussion about this whole issue and it’s off topic, so I’ll leave any thoughts on the matter to you). If you’re really interested in the detailed math, check out the articles Why Use Radians instead of Degrees? and Radians and Degrees. The bottom line is that Microsoft uses radians, not degrees, when providing trigonometric functions to make them mathematically correct, but completely confusing to the rest of us.

The example uses a measurement of 45 degrees as input to the trigonometric functions: Atn(), Sin(), Cos(), and Tan(). However, to make the input work correctly with the functions, you must first convert the degrees to radians. The corrected example looks like this:

Public Sub ScientificCalcs()
    ' Define an input value
    Dim MyInt As Integer
    MyInt = 45
     
    ' Convert input to radians.
    Dim Converted As Double
    Converted = WorksheetFunction.Radians(MyInt)
     
    ' Create an output string.
    Dim Output As String
     
    ' Display the trigonometric values for a 45 degree
    ' angle.
    MsgBox "The original angle is: " + CStr(MyInt) + _
           vbCrLf + "The value in radians is: " + CStr(Converted) + _
           vbCrLf + "Arctangent is: " + CStr(Atn(Converted)) + _
           vbCrLf + "Cosine is: " + CStr(Cos(Converted)) + _
           vbCrLf + "Sine is: " + CStr(Sin(Converted)) + _
           vbCrLf + "Tangent is: " + CStr(Tan(Converted)), _
           vbOKOnly, _
           "Trigonometric Values"
            
    ' Change the sign of the number using Sgn and Int.
    ' Add the value to Output each time.
    Output = "The sign of 0 is: " + CStr(Sgn(0))
    MyInt = -45
    Output = Output + vbCrLf + _
             "The sign of " + CStr(MyInt) + " is: " + _
             CStr(Sgn(MyInt))
    MyInt = Abs(MyInt)
    Output = Output + vbCrLf + _
             "The sign of " + CStr(MyInt) + " is: " + _
             CStr(Sgn(MyInt))
    MsgBox Output, vbOKOnly, "Using Sgn and Abs"
End Sub

Actually, the updated example also demonstrates the use of the WorksheetFunction object, which is something that isn’t covered well in the book now. Notice how the code converts the number of degrees into radians using the WorksheetFunction.Radians() function. The WorksheetFunction object provides access to a host of useful functions and you really need to check it out if you work with Excel on a regular basis. The new version of this example outputs the correct values for sine, cosine, tangent, and arctangent as shown here.

ScientificExample

Please let me know if you have any questions about this updated example. Let me know about any other concerns you have about this book at John@JohnMuellerBooks.com.