The question:
What does mean by Optimizer in MS SQL ? What is it ?
How do you use it ? what are the benifits of use it ?
The accepted answer by Derekman:
The query optimizer is the component of SQL server that determines the most efficient way to execute a query based upon the distribution statistics and histograms maintained within sql server. When you pass a query to sql server the query is optimized based on the estimated "cost" of the query for the different possible ways to exeute the statement based on the table(s) and index(es) available. SQL Server query optimizer reviews the different options in which to execute the query and decides on the most efficient way based on overall cost. Most, but not all, queries are optimized automatically and you do not need to do anything to invoke query optimization. There are however "query hints" that allow you to over ride a query plan recommended by the optimizer.
Please review BOL and the below link for a more detailed explanation.
Best of Luck!!
Labels: optimization, sql
The question:
My program has an option for running at startup.
I need a way to add a registry key to:
HKEY_Current_User\Software\Microsoft\Windows\CurrentVersion\Run\
And Remove it as well.
I've looked in to some other stuff but it seems way to complicated for what i need.
The accepted answer by Moayad Mardini:
To add a value to that key :
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", YourProgramName, YourProgramPath, Microsoft.Win32.RegistryValueKind.String)
Then to delete it :
My.Computer.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue(YourProgramName)
Hope this helps
The question:
Ok i have an unbound text box
i also have a command button that does nothing.
I need to be able to have whatever i type into the text box to be entered into a table.
how can i do this?
for the record i know extremely little about VBA, i can copy and paste, and edit bits if im told what, when and where to edit but apart from that i'm useless.
Any help will be greatly appreciated.
The accepted answer by Spotty:
From what you said, you are leaving out real important points
A table, what sort of database are you using, does you applicable actually already use the database in any way already ?
What version of VB are you using ?
All these points determine a solution. The technology you are probably going to be using is called ADO.NET and you are going to be using a Command Object. A web search on ADO.NET + VB.NET + INSERT QUERY will probably reveal quite a few basic examples.
Something a simple as may work.
Dim con As SqlConnection
Try
con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI")
con.Open()
Dim cmd As New SqlCommand()
cmd.Connection = con
cmd.CommandText = "INSERT INTO Employee (FirstName) VALUES (@FirstName)"
' 2. Map parameters
cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 10, "FirstName")
cmd.Parameters("@FirstName").Value = Textbox1.text
cmd.ExecuteNonQuery()
Finally
con.Close()
End Try
The question:
I am trying to list all of the currently open windows that are in the taskbar. Does anybody know how to do that?
Thanks in advance.
The accepted answer by Tall Dude:
If you just want the applications,
(not all windows,) try:
Public Class Form1
' Derived from code at:
' http://www.thescarms.com/vbasic/alttab.aspx
Declare Function EnumWindows Lib "user32" _
(ByVal lpEnumFunc As CallBack, ByVal lParam As Integer) As Integer
Declare Function GetForegroundWindow Lib "user32" () As Integer
Declare Function GetParent Lib "user32" (ByVal hwnd As Integer) As Integer
Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Integer, ByVal wCmd As Integer) As Integer
Declare Function GetWindowInteger Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Integer, ByVal nIndex As Integer) As Integer
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal hwnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer
Declare Function IsIconic Lib "user32" (ByVal hwnd As Integer) As Integer
Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Integer) As Integer
'
' Constants used with APIs
'
Public Const SW_SHOW = 5
Public Const SW_RESTORE = 9
Public Const GW_OWNER = 4
Public Const GWL_HWNDPARENT = (-8)
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_TOOLWINDOW = &H80
Public Const WS_EX_APPWINDOW = &H40000
'
Public Delegate Function CallBack(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean
Public Shared Function fEnumWindowsCallBack(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean
Dim lReturn As Integer
Dim lExStyle As Integer
Dim bNoOwner As Boolean
Dim sWindowText As String
'
' This callback function is called by Windows (from
' the EnumWindows API call) for EVERY window that exists.
' It populates the listbox with a list of windows that we
' are interested in.
'
' Windows to display are those that:
' - are not this app's
' - are visible
' - do not have a parent
' - have no owner and are not Tool windows OR
' have an owner and are App windows
'
If hwnd <> Form1.Handle Then
If IsWindowVisible(hwnd) Then
If GetParent(hwnd) = 0 Then
bNoOwner = (GetWindow(hwnd, GW_OWNER) = 0)
lExStyle = GetWindowInteger(hwnd, GWL_EXSTYLE)
If (((lExStyle And WS_EX_TOOLWINDOW) = 0) And bNoOwner) Or _
((lExStyle And WS_EX_APPWINDOW) And Not bNoOwner) Then
'
' Get the window's caption.
'
sWindowText = Space$(256)
lReturn = GetWindowText(hwnd, sWindowText, Len(sWindowText))
If lReturn Then
'
' Add it to our list.
'
sWindowText = Trim(sWindowText)
Form1.ListBox1.Items.Add(sWindowText)
End If
End If
End If
End If
End If
fEnumWindowsCallBack = True
End Function
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
EnumWindows(AddressOf fEnumWindowsCallBack, 0)
End Sub
End Class
Labels: application, open, windows
The response by Martin Xie - MSFT:
By means of Convert class, you can first convert Binary to Decimal Intger, and then convert Decimal to Octal and Hexadecimal string.
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Friend Class Program
Shared Sub Main(ByVal args As String())
Dim bin As String = "1000001" 'Binary string
Dim decimalValue As Integer
Dim hexValue As String
Dim OctalValue As String
decimalValue = Convert.ToInt32(bin, 2) 'First convert Binary to Decimal Intger
Console.WriteLine("Decimal:" & decimalValue)
OctalValue = Oct(decimalValue) 'Convert Decimal to Octal string
Console.WriteLine("Octal:" & OctalValue)
hexValue = Hex(decimalValue) 'Convert Decimal to Hexadecimal string
Console.WriteLine("Hexadecimal:" & hexValue)
Console.Read()
End Sub
End Class
The output will be:
Decimal: 65
Octal: 101
Hexadecimal: 41
The question:
Hello! Hope someone could help me on converting ASCII characters to Binary
Also,hope you know how to convert Boolean Number to Octal or Hexadecimal or Decimal number.
Thanks in advance!
The accepted answer by Martin Xie - MSFT :
Hi rattlesnake,
ASCII can only represent character codes between 0 and 127.
About converting ASCII characters to Binary,
e.g. convert AscII value 66 of character B to Binary like this:
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Friend Class Program
Shared Sub Main(ByVal args As String())
Dim myChar As Char = "B"c
Dim j As Integer = 0
Dim ascii As Integer = System.Convert.ToInt32(myChar)
Console.WriteLine("ASCII:" & ascii)
Dim binTempResult As String = ""
Do While ascii > 0
j = ascii Mod 2
binTempResult &= j.ToString()
ascii = ascii \ 2
Loop
'reverse output
Dim arr As Char() = binTempResult.ToCharArray()
Array.Reverse(arr)
Dim binResult As String = New String(arr)
System.Console.Write(binResult)
Console.Read()
End Sub
End Class
The output will be:
ASCII:66
1000010
The question:
Upon updateing a combobox to select the sex of a farm animal I am attempting to filter out the opposite sex in the next ID box.Can anyone see where my issue is here. I have rewritten this many time to no avail. I have read through the msdn help on this and all appears to be done correctly. Also... How would I use one of these filters to show only discrete items?
http://imkaudio.com/error/nocolumnerror.bmp
And here is the code
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Ct10DataSet.animal' table. You can move, or remove it, as needed.
Me.AnimalTableAdapter.Fill(Me.Ct10DataSet.animal)
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Me.AnimalBindingSource1.Filter = "Sex = " & ComboBox1.SelectedValue.ToString()
End Sub
End Class
The Accepted answer by ahmedilyas :
try this:
Me.AnimalBindingSource1.Filter = "Sex = '" & ComboBox1.Text & "'"
Labels: binding source
How we installed the Digg button on blogger?
Find out here how this has been done : http://howtosuccesswithblogging.blogspot.com/2008/03/addition-of-digg-button-to-blogger.html
Labels: flashnews
The Question:
I have a form with datagrid on it, but when i fill the grid with a table, the columns do not take up the entire space that is available in the datagrid. Also the individual column sizes do not show all the data in the field, i have to resize it using drag feature, but i have the space on the form when i first load it and i want the columns to take up all the space available in the datagrid.
The accepted answer by Riquel Dong – MSFT:
Based on your post, you need to change the width of the row or column in a DataGrid. You can use the DataGridTableStyle class to implement this.
it represents the table drawn by the System.Windows.Forms.DataGrid control at run time. Its property GridColumnStyles allows you to create a customized set of column styles. Pleaser read this article Advanced DataGrid Sizing for this problem. It shoulds help your to handle this problem. Here is the code exmaple about sizing the datagrid control. Hope this helps.
Public Class Form5
Dim dt As DataTable
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataGrid1.Width = 450
dt = New DataTable
dt.Columns.Add("id", GetType(Integer))
dt.Columns.Add("name", GetType(String))
dt.Columns.Add("region", GetType(String))
For i As Integer = 0 To 5
dt.Rows.Add(i, "name " & i.ToString, "region " & i.ToString)
Next
Dim style As DataGridTableStyle = New DataGridTableStyle()
style.MappingName = dt.TableName
For Each column As DataColumn In dt.Columns
Dim gridColumn As DataGridTextBoxColumn = New DataGridTextBoxColumn()
gridColumn.MappingName = column.ColumnName
gridColumn.HeaderText = column.ColumnName
gridColumn.Width = 135
style.GridColumnStyles.Add(gridColumn)
Next
DataGrid1.TableStyles.Clear()
DataGrid1.TableStyles.Add(style)
DataGrid1.DataSource = dt
End Sub
End Class
Best regards,
Riquel
Labels: datagrid
Blog aim:
Our blog quest is to keep in track of all successful and answered post in the MSDN Forums.
So you can easily get the top answers from this blog. We have 20 post in different categories, just make a search and you should find what you are searching for!
Having a good tutorial or article about MS technology?
We'll post you article on our blog! Just leave a comment including your tutorial address and I'll post it here. You'll get also a link ;)
You can also send it to me by email: omar.abid2006@gmail.com
Other Dot Net blogs:
The Dot Net Source
My Blogger
My Wordpress
Blog traffic: For webmasters
December 2007 : 1 080 visitor ( 1 230 page views)
January 2008 : 1 633 visitor ( 2 036 page views)
February 2008 : 2 010 ( 2 885 page views)
March 2008 : 2 660 ( 3 125 page views)
April 2008 : 3 210 ( 4 452 page views)
May 2008 : 3 885 ( 5 062 page views)
The Question :
| |
| |||
The Accepted answer by Martin Xie - MSFT
Hi mjwsoft,
I agree with spotty. C++ may be more suitable for programming Firewall.
If you wish to do it in VB.NET, you need to P/Invoke Packet Filtering API.
The Firewall service usually is based on packet filtering technology.
Here are some references.
1. Simple Packet - Filter Firewall
Working of firewall is based on the following steps:
- Extract the packet header
- Check the protocol associated
- Compare with the rules
- Check the source and destination add. If protocol is same
- Check out the port if protocol is TCP
- Drop or pass the packet
2. Packet Filtering API on MSDN
http://msdn2.microsoft.com/en-us/library/Aa376636.aspx
Packet Filtering API allow us to associate filters to IP adapter interfaces. We can implement a functionality similar that included in TCP/IP filter options in TCP/IP properties of a network adapter.
Class library to implement packet filtering funcionality in your .NET applications
4. In addition, here is a Firewall SDK which helps deveopers create and manage a firewall control easily.
The Gtfctrl.dll wraps all the firewall operations in one "Firewall Panel", it can be used in VB.Net , C#.Net.
http://www.xanv.com/firewall-sdk.html
5. You also can find some ideas in this thread.
How to build a firewall like AVG Firewall in c#
Best regards,
Martin
I just found a great web site by searching the MSDN Forums.
I suddenly found a great website : http://www.getfreebudget.com/DevCntr.htm made by Jeff an active MSDN forums member.
It contains hundred of samples controls and lot more.
Take your time visiting it.
I had just add a new feature for the MSDN Forum Tracker Blog.
Now Good Code snippet will be converted depending on their langauge. If it's VB.net then it will be C# and Vice Versa.
This will help both VB.net and C# developer get the tragted code without looping in different code engine convertion.
Our Code Convertion is powered by Developer Fusion, you can find it here : http://labs.developerfusion.co.uk
If you have other suggestion, don't hesitate post a comment!
The Question :
Hi,
I am reading some binary data through my COM Port.
On my form are 2 multi-line text boxes and 14 single line text boxes.
Currently I convert the binary data into hex and display it in one of the multi-line text boxes.
I convert the binary data into hex as each byte is read and then display it.
I would like to also display the binary data into ascii in the other multi-line text box. And also split the whole ascii string into substrings at certain points and display each one in the single line text boxes. I would like to process this all at the same time? How can this be done?
Cheers
Mark
The Accepted Answer (By Martin Xie - MSFT)
Hi Mark,
Currently I convert the binary data into hex and display it in one of the multi-line text boxes. I convert the binary data into hex as each byte is read and then display it.
Spaceman1972 wrote:
By means of Convert class, you can first convert Binary to Decimal Intger, and then convert Decimal to Hexadecimal string, finally assign it to the TextBox.Text property.
Imports Microsoft.VisualBasic Imports System Imports System.Collections.Generic Imports System.Text Dim bin As String = "1000001" 'Binary string Dim decimalValue As Integer Dim hexValue As String decimalValue = Convert.ToInt32(bin, 2) 'First convert Binary to Decimal Intger hexValue = Hex(decimalValue) 'Convert Decimal to Hexadecimal string TextBox.Text = hexValue 'Display it in the multi-line textbox
I would like to also display the binary data into ascii in the other multi-line text box. And also split the whole ascii string into substrings at certain points and display each one in the single line text boxes. I would like to process this all at the same time? How can this be done?
Spaceman1972 wrote:
You can first convert Binary data to Decimal Intger (as ASCII Codes), and then convert ASCII Codes to ASCII Characters, finally assign it to the TextBox.Text property.
Dim bin As String = "1000001" 'Binary string (A's ASCII Code 65)
Dim decimalAscIIValue As Integer
decimalAscIIValue = Convert.ToInt32(bin, 2) 'First convert Binary to Decimal Intger
Dim AscIIChar As String = Chr(decimalAscIIValue) 'Then convert Decimal to ASCII Character
TextBox.Text = AscIIChar 'AscIIChar =A. Display it in the multi-line textbox
I hope this can enlighten you.
I believe you can finish the rest task.
Best regards,
Martin Xie
The Question :
How can I get all the possible combinations of numbers?
For example the input numbers are 1, 2 and 3
How can i get all the possible combinations of these numbers
For example
1 2 3
3 2 1
3 1 2
2 1 3
2 3 1
1 3 2
How can i get all of this??? The numbers depends on the input for example the input numbers are from 1 - 9
how can i get all the possible combinations for that.
Hope someone could help me out here...
Thanks in advance!
The Best Answer by Robert Rossney :
Recursion is the key. To find all of the permutations of an n-element set, find, for each element in the set, all of the permutations of the n-element subset that doesn't contain that element.
Here's an implementation. It's not very efficient (an efficient algorithm would keep the current permutation in an array that it passes by reference, instead of accumulating it in a string), but it's correct:
class Program { static int count; static void Main(string[] args) { char[] set = new char [] { 'a', 'b', 'c' }; FindPermutations(String.Empty, set); Console.WriteLine("{0} permutations found", count); Console.ReadLine(); } static void FindPermutations(string permutation, char[] set) { if (set.Length == 1) { Console.WriteLine(permutation + set[0]); count++; return; } for (int i = 0; i <> { char n = set[i]; string newPermutation = permutation + n; char[] subset = new char[set.Length - 1]; int j = 0; for (int k = 0; k <> { if (set[k] != n) { subset[j++] = set[k]; } } FindPermutations(newPermutation, subset); } } } The Code converted to VB.net
Shared count As Integer
PrivateSharedSub Main(ByVal args As String())
Dim [set] As Char() = New Char() {"a"C, "b"C, "c"C}
FindPermutations([String].Empty, [set])
Console.WriteLine("{0} permutations found", count)
Console.ReadLine()
EndSub
PrivateSharedSub FindPermutations(ByVal permutation As String, ByVal [set] As Char())
If [set].Length = 1 Then
Console.WriteLine(permutation + [set](0))
count += 1
Return
EndIf
For i As Integer = 0 To [set].Length - 1
Dim n As Char = [set](i)
Dim newPermutation As String = permutation + n
Dim subset As Char() = New Char([set].Length - 2) {}
Dim j As Integer = 0
For k As Integer = 0 To [set].Length - 1
If [set](k) <> n Then
subset(System.Math.Max(System.Threading.Interlocked.Increment(j),j - 1)) = [set](k)
EndIf
Next
FindPermutations(newPermutation, subset)
Next
EndSub
EndClass
The Question :
I have a listbox with roughly 2500 items that were sorted when created. Now I want to re-sort the same listbox using the time and date portion of the string. Shown below are 5 items as is and then how I'd like the re-sort to place them in the listbox.
Initial Sort
25536_002 9/20/2007 10:37:04 PM
25536_002 9/20/2007 10:41:04 PM
25536_002 8/27/2007 8:41:17 AM
26875_001 9/20/2007 1:48:18 PM
26875_001 9/19/2007 12:38:12 PM
Final Sort
25536_002 8/27/2007 8:41:17 AM
25536_002 9/20/2007 10:37:04 PM
25536_002 9/20/2007 10:41:04 PM
26875_001 9/19/2007 12:38:12 PM
26875_001 9/20/2007 1:48:18 PM
I am hoping for a simple resolution.
Thanks,
RobertMC
The Accepted Answer (by Solitaire)
This is not so simple, involving some string manipulation, but I tested it with your sample data and it works.
Code Block
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim L As Integer, strdat As String
L = ListBox1.Items.Count
Dim strdate(L) As String
For x As Integer = 0 To L - 1
ListBox1.SelectedIndex = x
strdat = ListBox1.SelectedItem.ToString.Substring(20)
strdate(x) = strdat.PadRight(13) & (ListBox1.SelectedItem.ToString).Substring(0, 20)
Next x
ListBox1.Items.Clear()
For x As Integer = 0 To L - 1
ListBox1.Items.Add(strdate(x))
Next x
ListBox1.Sorted = True
For x As Integer = 0 To L - 1
ListBox1.SelectedIndex = x
strdat = ListBox1.SelectedItem.ToString.Substring(14)
strdate(x) = strdat & (ListBox1.SelectedItem.ToString).Substring(0, 13)
Next x
ListBox1.Items.Clear()
For x As Integer = 0 To L - 1
ListBox1.Items.Add(strdate(x))
Next x
End Sub
Sometimes the idea of using the debugger, can be intimdating to those unfamiliar with them.
This is a tutorial based in a standard piece a source code that we will supply for the purposes of this tutorial. We're going to make a cheap MP3 player. I hope this tutorial is highly interactive and constructive.
Needed Ingredients:
1.) A test directory with about 4 mp3 files. Make them as short as possible.
2.) Create a new Windows project. In the form Designer, add:
a.) A progressbar called progressbar b.) Two buttons, One named btPlay and the other called btStop. In their respective text property boxes in the designer, insert Play and Stop. c.) A windows Media Player control. This probably is not in your toolbox. Go to Tools Choose Toolbox Items COM Windows Media Player. It will now appear at the bottom of your toolbox. Add a media player to your form and name it wmp in it's properties window in the forms designer.
3.) Close the Project to write it to a directory and re-open it
4.) Go to the source editor and depress Control-A and then depress the delete Key.
5.) Then select, copy and paste the following source code:
Imports AxWMPLib
Imports WMPLib
Imports System.Runtime.InteropServices
Public Class Form1
Protected Friend WithEvents tmr As New Timer
Private Duration As Single
Const SongDirectory As String = "InsertYourTestDirectoryPathHere"
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
tmr.Interval = 1000 : tmr.Stop()
dim a as integer = 0 'Demo not relevant to the code
a = 1 'Demo not relevant to the code
End Sub
Private Sub btPlay_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles btPlay.Click
NewSong()
End Sub
Private Sub NewSong()
Dim Song as String = ""
ProgressBar.Value = 0
Song = ChooseRandomSong()
if Song <> "" then
wmp.URL = song
wmp.Ctlcontrols.play()
else
btPlay.enabled = false
beep()
end if
End Sub
Private Sub tmr_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tmr.Tick
If wmp.playState = WMPPlayState.wmppsPlaying Then
ProgressBar.Value = _
(wmp.Ctlcontrols.currentPosition / Duration) * 100
Else
tmr.Stop()
btPlay.PerformClick()
End If
End Sub
Private Sub Player_PlayStateChange(ByVal sender As System.Object, _
ByVal e As _ AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) _
Handles wmp.PlayStateChange
Dim NewState As WMPPlayState = e.newState
Select Case e.newState
Case WMPPlayState.wmppsBuffering
Case WMPPlayState.wmppsMediaEnded
ProgressBar.Value = 0
Case WMPPlayState.wmppsPaused
Case WMPPlayState.wmppsPlaying
Duration = wmp.currentMedia.duration
tmr.Start()
Case WMPPlayState.wmppsReady
Case WMPPlayState.wmppsReconnecting
Case WMPPlayState.wmppsScanForward
Case WMPPlayState.wmppsScanReverse
Case WMPPlayState.wmppsStopped
Case WMPPlayState.wmppsTransitioning
Case WMPPlayState.wmppsWaiting
Case Else
End Select
End Sub
Private Function ChooseRandomSong() As String
Dim DI As New System.IO.DirectoryInfo(SongDirectory)
Dim fi() As System.IO.FileInfo = DI.GetFiles()
Static Song As String = ""
Static LastSong As String = ""
Static SongList As New List(Of String) : SongList.Clear()
For Each file As System.IO.FileInfo In fi
If file.Extension.ToLower = ".mp3" Then
SongList.Add(file.FullName)
End If
Next
If SongList.Count = 0 Then Return ""
Static rnd As New Random
Static num As Int32
Song = LastSong
While Song = LastSong
num = rnd.Next(SongList.Count)
Song = SongList(num)
End While
LastSong = Song
SongList.Clear()
Return Song
End Function
End Class
Please note the board editor introduces spurious line wraps and may introduce syntax errors around continuations. if you see squiggles after adding everything, make all lines with the continuation character "_" one line, deleting the "_" and the space in front of it.
Be sure to insert your mp3 directory here:
Const SongDirectory As String = "InsertYourTestDirectoryPathHere"
Depress the save all files button above.
Go to View Toolbars and make sure that the debug toolbar is checked.
1.) Go to the source editor
2.) Find this line in the load event tmr.Interval = 1000 : tmr.Stop() (These are actually two lines of code separated by a ":".
3.) On exactly the same horizontal level as that line, to the left of the editor, do a single left click. A brown dot should appear. click until a brown dot does apear. [see Dave's comments below]
4.) In the debug toolbar, make sure the locals windows is depressed (activated).
5.) Depress the Green right triangle up above.
6.) What happened?
7.) Make sure you can see the Locals window.
8.) In the debugger toolbar, you will see the Green Arrow, and a [] square. To the right you will see a button with the a line and arrow pointing into the middle of lines. This is the "Step Into" control. On its right you will see the the "Step Over" control.
9.) Watching the Locals window, depress the Step Into button and look for a
10.) Depress the Step Into Button and look at a now.
11.) Finally depress the Green arrow.
What Happened?
1.) Make sure the debugger is not running. [ ] Button
2.) Go to your single existing break point by putting your cursor on the Brown dot representing the break point and left click on it. The Break point is deleted.
Now let's see if your project is working.
3.) Making sure your speakers are on, Depress the Green arrow, and your project should appear on the screen.
4.) Depress the Play button and you should hear one of your mp3s startup. Allow it to play through.
5.) While listening, put a new break point on this line:
Private Sub NewSong()
ProgressBar.Value = 0 ' Set a break here and wait for the ' song to finish.
6.) Depress the Step Over Button and observe the editor.
7.) Stop the project [ ].
8. Repeat step 4 and then 9.
9.) This time, depress the step into button oberving what happens, depress it again and again and again.
What was different?
1.) Stop your project [ ] and delete all of your previous break points.
2.) Insert a break point at this Next Statement
For Each file As System.IO.FileInfo In fi
If file.Extension.ToLower = ".mp3" Then
SongList.Add(file.FullName)
End If
Next
3.) Start your project with the Green Arrow. Depress the Play Button.
4.) When your breakpoint is reached, place your cursor here:
Static SongList As New List(Of String) : SongList.Clear()
on Songlist
5.) A window will appear. Put your mouse on the + boxes and new windows will appear
6.) Follow the + signs to the end.
7.) Depress the green arrow so you execute the loop again. Repeat steps 4 -6
8.) Repeat 7 again and again.
9.) Stop your Project
10.) Delete all Breakpoints
11. Place a breakpoint Here:
While Song = LastSong
num = rnd.Next(SongList.Count)
Song = SongList(num)
End While
LastSong = Song
SongList.Clear()Return Song ‘ Set your breakpoint here.
12.) Start your project
13.) Depress Play
What is the contents of Song?
1.) Stop your project.
2.) Delete your breakpoints.
3.) Place a point here:
Private Sub btPlay_Click(ByVal sender As Object, _
4.) Start your project
5.) Press Play......
6.) After observing that. Stop your project and delete all break points
7.) Place a break point here:
Private Sub tmr_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tmr.Tick
If wmp.playState = WMPPlayState.wmppsPlaying Then
ProgressBar.Value = _
(wmp.Ctlcontrols.currentPosition / Duration) * 100
Else
tmr.Stop()
btPlay.PerformClick()
End If
End Sub
At tmr.stop
8.) Start your prject with the green arrow
9.) Depress Play
10.) Listen to the music until the end and watch the screen......