Good Day All, I have another question: I have done this program to sort a list of artist and their biggest hits, etc. It has 4 parallel arrays that i have to sort alphabetically using the Sort Option in the menu bar. I am using Bubble sort, to sort the four arrays. I have done a similar sort in another program, with the difference that the sort was located in a JComboBox, then it worked perfectly. But now that the Sort option is in the menubar, i cannot seem to get my Bubble Sort to work. Can anyone please give me some ideas? Is the bubble sort not supposed to work irrespective of if you use it with a JComboBox or a menu item? Or perhaps I just don't understand Bubble Sort. Any other suggestions to sort parallel String Arrays would also be welcomed. Thank You.
I am attaching the code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.*;

public class MusicArtists extends JFrame implements ActionListener
{
	//Initialize data in arrays
	String artist[] = {"Colbie Caillat", "Sara Bareilles", "Meatloaf", "Alannis Morissette"};
	String genre[] = {"Pop", "Pop", "Rock", "Rock"};
	String hit[] = {"Bubbly", "Love Song", "Bat out of Hell", "Ironic"};
	String label[] = {"PCM Audio", "Epic", "Mercury", "RPG"};

	//Construct components
	JTextPane textPane = new JTextPane();

	//Construct instance of Favorite Music Artists
	public MusicArtists()
	{
		super("Favorite Music Artists");
	}

	//Creating menu system
	public JMenuBar createMenuBar()
	{
		//Create instance of menu
		JMenuBar mnuBar = new JMenuBar();
		setJMenuBar(mnuBar);

		//Construct and populate Edit Menu
		JMenu mnuEdit = new JMenu("Edit", true);
			mnuEdit.setMnemonic(KeyEvent.VK_E);
			mnuEdit.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuEdit);

		JMenuItem mnuEditInsert = new JMenuItem("Insert new Data");
			mnuEditInsert.setMnemonic(KeyEvent.VK_I);
			mnuEdit.setDisplayedMnemonicIndex(0);
			mnuEdit.add(mnuEditInsert);
			mnuEditInsert.setActionCommand("Insert");
			mnuEditInsert.addActionListener(this);

		JMenu mnuSortBy = new JMenu("Sort by", true);
			mnuSortBy.setMnemonic(KeyEvent.VK_S);
			mnuSortBy.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuSortBy);

		JMenuItem mnuSortByArtist = new JMenuItem("Artist");
			mnuSortByArtist.setMnemonic(KeyEvent.VK_A);
			mnuSortByArtist.setDisplayedMnemonicIndex(0);
			mnuSortBy.add(mnuSortByArtist);
			mnuSortBy.setActionCommand("Artist");
			mnuSortBy.addActionListener(this);

		JMenuItem mnuSortByGenre = new JMenuItem("Genre");
			mnuSortByGenre.setMnemonic(KeyEvent.VK_G);
			mnuSortByGenre.setDisplayedMnemonicIndex(0);
			mnuSortBy.add(mnuSortByGenre);
			mnuSortBy.setActionCommand("Genre");
			mnuSortBy.addActionListener(this);

		JMenuItem mnuSortByGreatestHit = new JMenuItem("Greatest Hit");
			mnuSortByGreatestHit.setMnemonic(KeyEvent.VK_H);
			mnuSortByGreatestHit.setDisplayedMnemonicIndex(9);
			mnuSortBy.add(mnuSortByGreatestHit);
			mnuSortBy.setActionCommand("Hit");
			mnuSortBy.addActionListener(this);

		JMenuItem mnuSortByRecordLabel = new JMenuItem("Record Label");
			mnuSortByRecordLabel.setMnemonic(KeyEvent.VK_L);
			mnuSortByRecordLabel.setDisplayedMnemonicIndex(7);
			mnuSortBy.add(mnuSortByRecordLabel);
			mnuSortBy.setActionCommand("Label");
			mnuSortBy.addActionListener(this);

		return mnuBar;
	}

	//Create content pane
	public Container createContentPane()
	{
		//Create JTextPane & center panel
		JPanel centerPanel = new JPanel();
			setTabsAndStyles(textPane);
			textPane = addTextToTextPane();
			JScrollPane scrollPane = new JScrollPane(textPane);
				scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
				scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
				scrollPane.setPreferredSize(new Dimension(550,200));
			centerPanel.add(scrollPane);

		//Create Container and set attributes
		Container c = getContentPane();
			c.setLayout(new BorderLayout(10,10));
			c.add(centerPanel, BorderLayout.CENTER);

		return c;

	}

	//method to create tab stops and set font styles
	protected void setTabsAndStyles(JTextPane textPane)
	{
		//create Tab Stops
		TabStop[] tabs = new TabStop[3];
			tabs[0] = new TabStop(150, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[1] = new TabStop(250, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[2] = new TabStop(400, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
		TabSet tabset = new TabSet(tabs);

		//set Tab Style
		StyleContext tabStyle = StyleContext.getDefaultStyleContext();
		AttributeSet aset =
			tabStyle.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabset);
		textPane.setParagraphAttributes(aset, false);

		//set Font Style
		Style fontStyle =
			StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

		Style regular = textPane.addStyle("regular", fontStyle);
		StyleConstants.setFontFamily(fontStyle, "Arial");

		Style s = textPane.addStyle("italic", regular);
		StyleConstants.setItalic(s, true);

		s = textPane.addStyle("bold", regular);
		StyleConstants.setBold(s, true);

		s = textPane.addStyle("large", regular);
		StyleConstants.setFontSize(s, 12);
	}

	//Add text to JTextPane
	public JTextPane addTextToTextPane()
	{
		Document doc = textPane.getDocument();
		try
		{
			//clear previous text
			doc.remove(0, doc.getLength());

			//insert Artist
			doc.insertString(0, "ARTIST\tGENRE\tGREATEST HIT\tRECORD LABEL\n", textPane.getStyle("large"));

			//insert detail
			for (int j = 0; j<artist.length; j++)
			{
				doc.insertString(doc.getLength(), artist[j] + "\t", textPane.getStyle("bold"));
				doc.insertString(doc.getLength(), genre[j] + "\t", textPane.getStyle("italic"));
				doc.insertString(doc.getLength(), hit[j] + "\t", textPane.getStyle("regular"));
				doc.insertString(doc.getLength(), label[j] + "\n", textPane.getStyle("regular"));
			}
		}
		catch (BadLocationException ble)
		{
			System.err.println("Couldn't insert text.");
		}

		return textPane;
	}

	//Event to process user clicks
	public void actionPerformed(ActionEvent e)
	{
		String arg = e.getActionCommand();

		//user clicks Insert new data on the Edit menu
		if (arg == "Insert")
		{
			//accept new data
			String newArtist = JOptionPane.showInputDialog(null, "Please enter the Artist name.");
			String newGenre = JOptionPane.showInputDialog(null, "Please enter the Genre");
			String newHit = JOptionPane.showInputDialog(null, "Please enter " + newArtist + "'s Greatest Hit.");
			String newLabel = JOptionPane.showInputDialog(null, "Please enter the Record Label.");

			//enlarge arrays
			artist = enlargeArray(artist);
			genre = enlargeArray(genre);
			hit = enlargeArray(hit);
			label = enlargeArray(label);

			//add new data to arrays
			artist[artist.length-1] = newArtist;
			genre[genre.length-1] = newGenre;
			hit[hit.length-1] = newHit;
			label[label.length-1] = newLabel;

			//call sort method
			sort(artist);
		}

		// user clicks Artist on Sort By menu
		if (arg.equals("Artist"))
			sort(artist);

		// user clicks Genre on Sort By menu
		if (arg.equals("Genre"))
			sort(genre);

		// user clicks Record Label on Sort By menu
		if (arg.equals("Record Label"))
			sort(label);

		// user clicks Greatest Hit on Sort By menu
		if (arg.equals("Greatest Hit"))
			sort(hit);
	}

	//Method to enlarge array by 1
	public String[] enlargeArray(String[] currentArray)
	{
		String[] newArray = new String[currentArray.length + 1];
		for (int i = 0; i<currentArray.length; i++)
			newArray[i] = currentArray[i];
		return newArray;
	}

	//Method to sort array
	public void sort(String tempArray[])
	{
		//loop to control number of passes
		for (int pass =1; pass < tempArray.length; pass++)
		{
			for (int element = 0; element < tempArray.length - 1; element++)
				if(tempArray[element].compareTo(tempArray[element + 1])>0)
				{
					swap(artist, element, element + 1);
					swap(genre, element, element + 1);
					swap(hit, element, element + 1);
					swap(label, element, element + 1);
				}
		}
			addTextToTextPane();
	}

	//Method to swap two element of an array
	public void swap(String swapArray[], int first, int second)
	{
		String hold; //temporary holding area for swap
		hold = swapArray[first];
		swapArray[first] = swapArray[second];
		swapArray[second] = hold;
	}

	//Main method execute at run time
	public static void main(String args[])
	{
		JFrame.setDefaultLookAndFeelDecorated(true);
		MusicArtists f = new MusicArtists();
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setJMenuBar(f.createMenuBar());
		f.setContentPane(f.createContentPane());
		f.setSize(600, 275);
		f.setVisible(true);
	}
}

Recommended Answers

All 10 Replies

You have a sort and you have your GUI. These should be completely independent of each other. The sort itself should have nothing to do with the GUI. When you write a bubble sort function, it either is correct or it isn't and it has nothing to do with whether the overall application has a GUI or not. If you've written it so that the bubble sort implementation DOES have something to do with the fact that you are using a GUI, a program redesign is in order, in my opinion.

Is the bubble sort not supposed to work irrespective of if you use it with a JComboBox or a menu item?

Combo box, menu item, it shouldn't matter. All of these things involve CALLING the sort function when an action occurs. The bubble sort should always work if written correctly.

Have you got an actionlistener added to the menus?

I have an action listener added to the menus and i think my bubble sort is written correctly. I have compared it with other bubble sort methods on the net as well and it looks the same, still my sorting does not work.
I will continue to try. I WILL find a solution. No sort will beat me ... :)
Thank You for your reply's ... more ideas are welcome.

I have an action listener added to the menus and i think my bubble sort is written correctly. I have compared it with other bubble sort methods on the net as well and it looks the same, still my sorting does not work.
I will continue to try. I WILL find a solution. No sort will beat me ... :)
Thank You for your reply's ... more ideas are welcome.

I stuck a breakpoint at the top of this function:

//Method to sort array
	public void sort(String tempArray[])
	{
		//loop to control number of passes
		for (int pass =1; pass < tempArray.length; pass++)
		{
			for (int element = 0; element < tempArray.length - 1; element++)
				if(tempArray[element].compareTo(tempArray[element + 1])>0)
				{
					swap(artist, element, element + 1);
					swap(genre, element, element + 1);
					swap(hit, element, element + 1);
					swap(label, element, element + 1);
				}
		}
			addTextToTextPane();
	}

The breakpoint isn't hit when you sort with the menu bar, so that means the function isn't being called. You say you have an action listener added to the menu, but do you have them added to the menu ITEMS? I see this line several times:

mnuSortBy.addActionListener(this);

but I don't see anything like this:

mnuSortByGenre.addActionListener(this);

Thank you for the advice, i have changed the code ... thank you, i initially did not understand why it had to be done, but as i went through my code, i understood. But, it still does not seem to work. The arrays still do not sort.

Thank you for the advice, i have changed the code ... thank you, i initially did not understand why it had to be done, but as i went through my code, i understood. But, it still does not seem to work. The arrays still do not sort.

Not sure what you changed, but try this, for instance, when sorting by record label. The others will be quite similar. Make sure that what is in red matches what's in red and what's in green matches what's in green below:

in createMenuBar function:

JMenuItem mnuSortByRecordLabel = new JMenuItem("Record Label");
			mnuSortByRecordLabel.setMnemonic(KeyEvent.VK_L);
			mnuSortByRecordLabel.setDisplayedMnemonicIndex(7);
			mnuSortBy.add(mnuSortByRecordLabel);
			mnuSortByRecordLabel.setActionCommand("Label");
			mnuSortByRecordLabel.addActionListener(this);

in actionPerformed function:

// user clicks Record Label on Sort By menu
if (arg.equals("Label"))
    sort(label);

Thank you, i have made the changes and will highlight in red another change that i have made, and now the sort is working. I just have one more question: Why is the sort method that i call to sort the array, sort(artist) and not sort(genre) or hit or label for that matter. (This is now te sort method that i have highlighted in red.) I would just like to understand what i do as well.

import java.awt.*;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.*;

public class MusicArtists extends JFrame implements ActionListener
{
	//Initialize data in arrays
	String artist[] = {"Colbie Caillat", "Sara Bareilles", "Meatloaf", "Alannis Morissette"};
	String genre[] = {"Pop", "Pop", "Rock", "Rock"};
	String hit[] = {"Bubbly", "Love Song", "Bat out of Hell", "Ironic"};
	String label[] = {"PCM Audio", "Epic", "Mercury", "RPG"};

	//Construct components
	JTextPane textPane = new JTextPane();

	//Construct instance of Favorite Music Artists
	public MusicArtists()
	{
		super("Favorite Music Artists");
	}

	//Creating menu system
	public JMenuBar createMenuBar()
	{
		//Create instance of menu
		JMenuBar mnuBar = new JMenuBar();
		setJMenuBar(mnuBar);

		//Construct and populate Edit Menu
		JMenu mnuEdit = new JMenu("Edit", true);
			mnuEdit.setMnemonic(KeyEvent.VK_E);
			mnuEdit.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuEdit);

		JMenuItem mnuEditInsert = new JMenuItem("Insert new Data");
			mnuEditInsert.setMnemonic(KeyEvent.VK_I);
			mnuEdit.setDisplayedMnemonicIndex(0);
			mnuEdit.add(mnuEditInsert);
			mnuEditInsert.setActionCommand("Insert");
			mnuEditInsert.addActionListener(this);

		JMenu mnuSortBy = new JMenu("Sort by", true);
			mnuSortBy.setMnemonic(KeyEvent.VK_S);
			mnuSortBy.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuSortBy);

		JMenuItem mnuSortByArtist = new JMenuItem("Artist");
			mnuSortByArtist.setMnemonic(KeyEvent.VK_A);
			mnuSortByArtist.setDisplayedMnemonicIndex(0);
			mnuSortBy.add(mnuSortByArtist);
			mnuSortByArtist.setActionCommand("Artist");
			mnuSortByArtist.addActionListener(this);

		JMenuItem mnuSortByGenre = new JMenuItem("Genre");
			mnuSortByGenre.setMnemonic(KeyEvent.VK_G);
			mnuSortByGenre.setDisplayedMnemonicIndex(0);
			mnuSortBy.add(mnuSortByGenre);
			mnuSortByGenre.setActionCommand("Genre");
			mnuSortByGenre.addActionListener(this);

		JMenuItem mnuSortByGreatestHit = new JMenuItem("Greatest Hit");
			mnuSortByGreatestHit.setMnemonic(KeyEvent.VK_H);
			mnuSortByGreatestHit.setDisplayedMnemonicIndex(9);
			mnuSortBy.add(mnuSortByGreatestHit);
			mnuSortByGreatestHit.setActionCommand("Hit");
			mnuSortByGreatestHit.addActionListener(this);

		JMenuItem mnuSortByRecordLabel = new JMenuItem("Record Label");
			mnuSortByRecordLabel.setMnemonic(KeyEvent.VK_L);
			mnuSortByRecordLabel.setDisplayedMnemonicIndex(7);
			mnuSortBy.add(mnuSortByRecordLabel);
			mnuSortByRecordLabel.setActionCommand("Label");
			mnuSortByRecordLabel.addActionListener(this);

		return mnuBar;
	}

	//Create content pane
	public Container createContentPane()
	{
		//Create JTextPane & center panel
		JPanel centerPanel = new JPanel();
			setTabsAndStyles(textPane);
			textPane = addTextToTextPane();
			JScrollPane scrollPane = new JScrollPane(textPane);
				scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
				scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
				scrollPane.setPreferredSize(new Dimension(550,200));
			centerPanel.add(scrollPane);

		//Create Container and set attributes
		Container c = getContentPane();
			c.setLayout(new BorderLayout(10,10));
			c.add(centerPanel, BorderLayout.CENTER);

		return c;

	}

	//method to create tab stops and set font styles
	protected void setTabsAndStyles(JTextPane textPane)
	{
		//create Tab Stops
		TabStop[] tabs = new TabStop[3];
			tabs[0] = new TabStop(150, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[1] = new TabStop(250, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[2] = new TabStop(400, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
		TabSet tabset = new TabSet(tabs);

		//set Tab Style
		StyleContext tabStyle = StyleContext.getDefaultStyleContext();
		AttributeSet aset =
			tabStyle.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabset);
		textPane.setParagraphAttributes(aset, false);

		//set Font Style
		Style fontStyle =
			StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

		Style regular = textPane.addStyle("regular", fontStyle);
		StyleConstants.setFontFamily(fontStyle, "Arial");

		Style s = textPane.addStyle("italic", regular);
		StyleConstants.setItalic(s, true);

		s = textPane.addStyle("bold", regular);
		StyleConstants.setBold(s, true);

		s = textPane.addStyle("large", regular);
		StyleConstants.setFontSize(s, 12);
	}

	//Add text to JTextPane
	public JTextPane addTextToTextPane()
	{
		Document doc = textPane.getDocument();
		try
		{
			//clear previous text
			doc.remove(0, doc.getLength());

			//insert Artist
			doc.insertString(0, "ARTIST\tGENRE\tGREATEST HIT\tRECORD LABEL\n", textPane.getStyle("large"));

			//insert detail
			for (int j = 0; j<artist.length; j++)
			{
				doc.insertString(doc.getLength(), artist[j] + "\t", textPane.getStyle("bold"));
				doc.insertString(doc.getLength(), genre[j] + "\t", textPane.getStyle("italic"));
				doc.insertString(doc.getLength(), hit[j] + "\t", textPane.getStyle("regular"));
				doc.insertString(doc.getLength(), label[j] + "\n", textPane.getStyle("regular"));
			}
		}
		catch (BadLocationException ble)
		{
			System.err.println("Couldn't insert text.");
		}

		return textPane;
	}

	//Event to process user clicks
	public void actionPerformed(ActionEvent e)
	{
		String arg = e.getActionCommand();
		//User Chooses to Sort the arrays
		if (e.getSource() == "mnuSortBy")
		{
			// user clicks Artist on Sort By menu
			if (arg.equals("Artist"))
				sort(artist);

			// user clicks Genre on Sort By menu
			if (arg.equals("Genre"))
				sort(genre);

			// user clicks Greatest Hit on Sort By menu
			if (arg.equals("Hit"))
				sort(hit);

			// user clicks Record Label on Sort By menu
			if (arg.equals("Label"))
			sort(label);

		}// end if

		//call Sort Method
		sort(artist);

		//user clicks Insert new data on the Edit menu
		if (arg == "Insert")
		{
			//accept new data
			String newArtist = JOptionPane.showInputDialog(null, "Please enter the Artist name.");
			String newGenre = JOptionPane.showInputDialog(null, "Please enter the Genre");
			String newHit = JOptionPane.showInputDialog(null, "Please enter " + newArtist + "'s Greatest Hit.");
			String newLabel = JOptionPane.showInputDialog(null, "Please enter the Record Label.");

			//enlarge arrays
			artist = enlargeArray(artist);
			genre = enlargeArray(genre);
			hit = enlargeArray(hit);
			label = enlargeArray(label);

			//add new data to arrays
			artist[artist.length-1] = newArtist;
			genre[genre.length-1] = newGenre;
			hit[hit.length-1] = newHit;
			label[label.length-1] = newLabel;

			//call sort method
			sort(artist);
		}
	}

	//Method to enlarge array by 1
	public String[] enlargeArray(String[] currentArray)
	{
		String[] newArray = new String[currentArray.length + 1];
		for (int i = 0; i<currentArray.length; i++)
			newArray[i] = currentArray[i];
		return newArray;
	}

	//Method to sort array
	public void sort(String[] tempArray)
	{
		//loop to control number of passes
		for (int pass = 1; pass < tempArray.length; pass++)
		{
			for (int element = 0; element < tempArray.length - 1; element++)
				if(tempArray[element].compareTo(tempArray[element + 1])>0)
				{
					swap(artist, element, element + 1);
					swap(genre, element, element + 1);
					swap(hit, element, element + 1);
					swap(label, element, element + 1);
				}
		}
			addTextToTextPane();
	}

	//Method to swap two element of an array
	public void swap(String swapArray[], int first, int second)
	{
		String hold; //temporary holding area for swap
		hold = swapArray[first];
		swapArray[first] = swapArray[second];
		swapArray[second] = hold;
	}

	//Main method execute at run time
	public static void main(String args[])
	{
		JFrame.setDefaultLookAndFeelDecorated(true);
		MusicArtists f = new MusicArtists();
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setJMenuBar(f.createMenuBar());
		f.setContentPane(f.createContentPane());
		f.setSize(600, 275);
		f.setVisible(true);
	}
}
//Event to process user clicks
	public void actionPerformed(ActionEvent e)
	{
		String arg = e.getActionCommand();
		//User Chooses to Sort the arrays
		if (e.getSource() == "mnuSortBy")
		{
			// user clicks Artist on Sort By menu
			if (arg.equals("Artist"))
				sort(artist);

			// user clicks Genre on Sort By menu
			if (arg.equals("Genre"))
				sort(genre);

			// user clicks Greatest Hit on Sort By menu
			if (arg.equals("Hit"))
				sort(hit);

			// user clicks Record Label on Sort By menu
			if (arg.equals("Label"))
			sort(label);

		}// end if

		//call Sort Method
		sort(artist);

		//user clicks Insert new data on the Edit menu
		if (arg == "Insert")
		{
			//accept new data
			String newArtist = JOptionPane.showInputDialog(null, "Please enter the Artist name.");
			String newGenre = JOptionPane.showInputDialog(null, "Please enter the Genre");
			String newHit = JOptionPane.showInputDialog(null, "Please enter " + newArtist + "'s Greatest Hit.");
			String newLabel = JOptionPane.showInputDialog(null, "Please enter the Record Label.");

			//enlarge arrays
			artist = enlargeArray(artist);
			genre = enlargeArray(genre);
			hit = enlargeArray(hit);
			label = enlargeArray(label);

			//add new data to arrays
			artist[artist.length-1] = newArtist;
			genre[genre.length-1] = newGenre;
			hit[hit.length-1] = newHit;
			label[label.length-1] = newLabel;

			//call sort method
			sort(artist);
		}
	}

Line 27 above causes lines 6 through 24 to have no effect. Say you try to sort by record label. You then immediately sort by artist afterwords, which makes the previous sort irrelevant. Note that there is no if statement attached to line 27. It executes no matter what, even if the action has nothing to do with any of the sorting menu items. Delete line 27. You have it covered in lines 8 through 22.

Delete lines 6, 7, and 24. You'll never get inside that if-statement and you don't need that if statement. You already have the four if statements inside of it. Those if statements do the job without the enveloping if statement.

So delete lines 6, 7, 24, and 27 and I think you'll have what you want.

Thank You, i have made the changes you suggested and it worked PERFECTLY. :D And after reading through the code again, it makes sense now and so does your explanation. Thank You very much for your assistance. :)

Thank You, i have made the changes you suggested and it worked PERFECTLY. :D And after reading through the code again, it makes sense now and so does your explanation. Thank You very much for your assistance. :)

You're welcome.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.