Archive for July 2007

In Reply To Comments Made On “Working With A Simple Structure Array In VB.NET”

Olive Oyl left the following comment in response to my blog post, “Working With A Simple Structure Array In VB.NET,” which responds to her Yahoo! Answers question:

Thank you!

I really appreciate all of the time and effort, and thought that has obviously gone into this answer.

I had already figured out the answer to the problem, and it is the same as what you have said here. This is really cool, the way this has been answered!

The other thing I was doing wrong with this problem is that the array must be declared in the public area of the form (I am not sure of the correct name for that area).

The instructor’s requirement was that the array should only be populated one time, when the form loads. That means that the display click event needs to be able to access it, so it has to be declared in the public area.

Thanks again! Hopefully this information will help others who are learning VB.NET.

p.s. I am almost certain that it is impossible to “assign a range of values, such as 0 to 299, to a variable ” as I tried to do.

I know that a scalar variable can hold ONLY one value at a time.

(Actually, she had left two comments, the second being a copy of her code, but it was incomplete due to the limitations of size in my blog comments box. I’ll update this post with her code if she wants to e-mail it to me for posting.)

There are a few parts of this comment I’d like to respond to more completely than I can in a follow-up comment, so here’s a second blog post on the subject.

Continue reading ‘In Reply To Comments Made On “Working With A Simple Structure Array In VB.NET”’ »

Displaying A Random Image From A Directory Via PHP, Part 2

In a recent blog post about randomly displaying an image from a directory via PHP and its built-in image and filesystem functions, I promised to expand upon the answer I had given to demonstrate some other cool filesystem tricks.

It’s about time I made good on that promise.

We’ll start by showing how to display a random image on a Web page, rather than forging the PHP to represent itself as an image; and we’ll also make a thumbnail gallery of all the images in the folder, which even shows the active image.

Continue reading ‘Displaying A Random Image From A Directory Via PHP, Part 2’ »

Working With A Simple Structure Array In VB.NET

Recently asked in Yahoo! Answers:

In Visual Basic.NET how do you assign a grading scale to an array of structure variables?

I want to assign a grading scale to an array of structure variables. HOW do you assign a range of values, such as 0 to 299, to a variable within a structure? (In Visual Basic.NET)

Example:
‘declare array of structure variables
Dim graGradingScale(4) As Grades
Dim intSearchfor As Integer
Dim intX As Integer = 0

‘assign grading scale to the array
graGradingScale(0).intPoints = 0 to 299
graGradingScale(0).strGrades = “F”

The part that needs to be changed is “0 to 299″ . How do you assign this range of values to the variable, so that if the user enters a 7, for example, the grade that will match that number will be “F”? I have the rest of the code done correctly, except this one part.

Here is the Grades structure:

Structure Grades
Public intPoints As Integer
Public strGrades As String
End Structure

As I understand the question, what this questioner wants is to create a five-cell array — each cell corresponding to a letter grade of A, B, C, D or F — and assign both the letter grade and the range of numbers needed to obtain that grade into a Structure (struct, for you C-language folks).

Then, she wants to be able to run an input value through the array, to see what letter grade the person should get.

Well, that’s pretty straightforward, but we need to make a couple minor modifications to the questioner’s methodology to make this work as desired. So let’s get to it.

Continue reading ‘Working With A Simple Structure Array In VB.NET’ »

A Simple YouTube Jukebox Using JavaScript / DOM And deconcept’s SWFObject

Recently asked on Yahoo! Answers:

HTML Help - Dropbox with Loading Option?

Okay, here’s my issue. I have a decent piece of coding that gives me a dropbox. The dropbox has a ‘go’ button, and it is filled with titles of music videos from YouTube.

Now, used alone, it’s fine. It opens a new page, which plays the youtube video.

However, I was clever enough to grab the *embed* names. So, it doesn’t load a simple youtube page, but simply the video in a website.

So now, I need some HTML help. I would like to create an object that sits next to the dropbox and plays the video when you select ‘go’, instead of it loading a new page.

I know how to make an embedded video. I know how to make the dropbox. Unfortunately, I don’t know how to make the dropbox and the embedded video interact, so that I can select the video I want to play.

This is very easy to do, thanks to deconcept’s excellent SWFObject JavaScript library and the questioner’s work in extracting the Flash FLV player URLs from all the videos he wants to show.

So, let’s get right on making a YouTube jukebox!

Continue reading ‘A Simple YouTube Jukebox Using JavaScript / DOM And deconcept’s SWFObject’ »