Tag Archives: example

Use VBA code to add and remove a watermark on all pages in a Word document

This post shows one way that you can add and remove a watermark in a Word document. To add a watermark in this way, you add a “building block” to the header of each of the document’s sections. If headers … Continue reading

Posted in Office, VBA | Tagged , , , , , , , | Leave a comment

Graph the gamma function in C#

The post Calculate the gamma function in C# uses numerical integration to calculate the gamma function. (See my book Essential Algorithms, Second Edition for information on numerical integration.) That method works fairly well for calculating Γ(x) where x ≤ 1. … Continue reading

Posted in algorithms, graphics, mathematics | Tagged , , , , , , , , | Leave a comment

Calculate the gamma function in C#

The gamma function, represented by the capital Greek letter gamma Γ, was derived by Daniel Bernoulli for complex numbers with a positive real part. The interesting thing about the gamma function is that &Gamma(n + 1) = n! for integers … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , | 1 Comment

Find rectangles defined by a side and aspect ratio in C#

You probably haven’t needed to make your program draw rectangles that are defined by specifying one of its sides. I haven’t either, but I want this for another program that I plan to write. Of course a single side isn’t … Continue reading

Posted in drawing, geometry, graphics | Tagged , , , , , , , , , | 3 Comments

Zip files with the ZipFile class in C#

The static ZipFile class is relatively new (.NET Framework 4.5 and later), so this example uses Visual Studio 2019. The following section explains how to load the ZipFile class in a Visual Studio 2019 project. The rest of this post … Continue reading

Posted in files | Tagged , , , , , , , , , | Leave a comment

Simulate a doubling betting strategy in C#

Casinos love customers who have a betting strategy because those customers always end up losing. As long as the game’s events are independent of each other (for example, one roll of the dice does not depend on the previous rolls), … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , | 1 Comment

Book Drawing: C++ All-in-One For Dummies, 4th Edition

John Mueller has kindly donated five copies of his book C++ All-in-One For Dummies, 4th Edition for me to give away. The only catch is that you should post a review on Amazon when you’ve had a chance to look … Continue reading

Posted in books | Tagged , , , , , , | Leave a comment

Use k-means clustering to find clusters of data in C#

I was recently editing John Mueller and Luca Massaron’s book Machine Learning For Dummies, Second Edition. (This link is for the first edition. I’ll try to remember to update it when the new edition is available.) The book is about … Continue reading

Posted in algorithms | Tagged , , , , , , , , | Leave a comment

Automatically set camera distance in WPF and C#

This example extends the post Build a geodesic sphere with WPF and C# to let you automatically set the camera distance to make the scene fill the viewport. Making a 3D scene fill the viewport nicely can be tricky. The … Continue reading

Posted in 3D graphics, algorithms, graphics, mathematics, wpf | Tagged , , , , , , , , , , , , , , , , | 6 Comments

Make numbered buttons in C#

This program lets you create a sequence of images that look like numbered buttons. It’s another program that I seem to recreate periodically. Click the Background and Foreground color swatches to change those colors. Use the numeric up/down controls to … Continue reading

Posted in drawing, graphics, user interface | Tagged , , , , , , , , , | Leave a comment