|
I am trying to use window media player in my dot net application. Iam able to add it in my application but not able to play the files through it I am using the following code for that-
dim str as string
str="c:\abc.mp3"
AxWindowsMediaPlayer1.URL = str
AxWindowsMediaPlayer1.Width = Me.centerbox.Width - 200
AxWindowsMediaPlayer1.Height = Me.centerbox.Height - 100
AxWindowsMediaPlayer1.Visible = True
it should play the file abc.mp3 . but it is not playing can any one help me please??
|
|
|
|
|
Using com1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("COM1")
com1.DtrEnable = True
Dim val As String = com1.ReadLine()
If val Is Nothing Then
MessageBox.Show("No Data Received")
Else
MessageBox.Show(val)
End If
end using
Problem: when i call "com1.ReadLine()" method the application become stuck and it gives no answer
plz reply me soon that what can i do further
Regards,
Yasir Riaz
|
|
|
|
|
It's waiting for information which is why your program hangs. You need to set the ReadTimeout. When it times out readline throws an error so be sure to wrap that statement in a try catch block.
|
|
|
|
|
Hi All,
I am using DataGrid view with Combobox and TextBox .....
so Iam initially using Combobox Values getting from database and select the combobox value and I Enter key pressed..but has to assiging the combobox value in Datagrid....
Pls tell me the coding part for assigning in DataGrid...and next cell using Textbox ...
and if i Enter key pressed ..but automatically textbox has to come and also Datagrid column has to come... pls tell me the related Coding part.......Pls help me ....advanced thanks....
Thanking you
somasundaram
|
|
|
|
|
Can anybody tell where I can download SqlHelper class (SqlHelper.vb)
for using in my application...
Thanks and regards,
cst...
dfdf
|
|
|
|
|
Hi frnds
i want to do in Grid that when i select the particular row at that time all the record of that selected row's information will display on the form.
|
|
|
|
|
Hi Guys
I was wondering if someone could help me figure out what I need to do to get this function to perform properly
Let me explain what I am doing.
I have an updating app to update a different app.
Since it is critical for internet connection to be valid I made a function to do the check. And not like microsoft and other boards suggest because that really only tells you you have a connection but not that you can actually communicate. For example I could change my IP address on my nic and not be able to browse yet it still says I'm connected.
So my function startecd off as a simple My.computer.network.ping
That was working great until I realized when I was at my friends house that some isp's block the ICMP request even though the connection is valid.
So I said ok I am going to change the ping to a lookup routine for a domain and if its address length=3 which means it found it then internet is available.
Now that works great in both situations where icmp is available or not except the delay in the check is slower than a straight ping request.
So what I was trying to do next was to first try the ping and if it didnt work try the nslookup and then return a value. It seems to be working but it seems to hang my machine.
I think I'm looped wrong or something. For example I have an animated gif on my main form that when it runs the function in dual mode moves at a snails pace. When I use either ping or nslookup alone it functions fine.
Do I need a background worker or something.
I'm sorry I am very new to programming and don't really even understand how to use background workers or if thats what I even need.
Maybe I just need to reorder my function.
In either case I will post my function code. If this info isn't sufficient I will add anything you need.
Thank you in advance
Tony
Private Function isConnected() As String
Try
If Not My.Computer.Network.Ping("www.google.com") Then GoTo TryNext
TryNext:
Dim AddressLength As IPHostEntry
AddressLength = System.Net.Dns.GetHostEntry("google.com")
If AddressLength.AddressList.Length.Equals(3) Then
'The above three lines works better then this in case icmp is unavailable
'If My.Computer.Network.Ping("www.google.com") Then
m_isNetConnected = "Available"
Return m_isNetConnected
Else
m_isNetConnected = "Unavailable"
Return m_isNetConnected
End If
Catch Except As System.Net.Sockets.SocketException
m_isNetConnected = "Unavailable"
Return m_isNetConnected
Catch Except As InvalidOperationException
m_isNetConnected = "Unavailable"
Return m_isNetConnected
End Try
End Function
|
|
|
|
|
Im sorry I forgot to add that this function is rechecked repeatedly by a timer so that it shows u if you are connected in realtime.
Thanks again
|
|
|
|
|
Well I think your function could be cleaned up a little bit. First of all it seems to me it should return a boolean value instead of a string. Secondly this next line of yours is pretty useless:
tgebrael wrote: If Not My.Computer.Network.Ping("www.google.com") Then GoTo TryNext
All this does is test if the ping succeeds and if it doesn't it skips to the next line. Skipping to the next line is unnecessary as your code would do that anyway without the goto statment. Also if it succeeds it again moves onto the next line and will execute the second method. So no matter what your function is trying both methods. This is one reason why you might find it slow. Instead of goto TryNext how about you just return "Available" or True if you decide to change it.
Also in every exception you have the same code. How about you move that code below the try catch block. It's just redundent. How about this:
Private Function isConnected() As Boolean
Try
'If ping succeed return
If My.Computer.Network.Ping("www.google.com") Then Return True
Dim AddressLength As IPHostEntry
AddressLength = System.Net.Dns.GetHostEntry("google.com")
'If lookup succeed return
If AddressLength.AddressList.Length.Equals(3) Then Return True
Catch Except As System.Net.Sockets.SocketException
'Catch exception
Catch Except As InvalidOperationException
'Catch exception
End Try
'If we got this far attempts failed. Return false
Return False
End Function
If you still want to return a string you could modify it back to how you had it.
Also if you'd like to use the backgroundworker try it out. It's pretty easy to use. I'm sure you can find info online about it. It has a DoWork event which fires when you call the method 'RunWorkerAsync'. The code in this event runs asyncronosly. So all you'd have to do is in the DoWork event call your function get the value and then pass it back to the main thread. There is a RunWorkerCompleted event which fires when the task is completed. You can pass the result on to it and then do whatever you want with the value.
|
|
|
|
|
TwoFace you are the man
Thank you so much
I had to make a couple mods to your code becuase it was the request timing out that was slowing me down but all in all it was very helpful to this newbie and very much appreciated.
Did I mention U ROCK
Tony
|
|
|
|
|
Hi,i have 2 drop down list box, in that one i am display year
another one display month,
when i am selecting the year and month,
i want to know how many sundays on that month like,
plz anyone can help me.........,
i need that code........
Regards,
Magi
|
|
|
|
|
The basic calculation is this. What you want to do is shift the calander so it starts on the day you are looking for. For instance if there are 31 days in the month and Sunday is the 3rd day then we'll throw out the first 2 days. This leaves us will 29 days (the first of which is sunday). If we divide 29 by 7 and round up, we end up with 5 which will be the number of Sundays in that month. Anyway, that's the principal behind this function I made. It takes 3 parameters. A Year and Month as well as the Day you are looking for. I used the DayOfWeek enum for the day parameter. 0 = Sunday, 1 = monday, ... 6 = saturday.
Private Function GetDaysInMonth(ByVal year As Integer, ByVal month As Integer, ByVal day As System.DayOfWeek) As Integer
'Date object for the first day of the month
Dim myDate As New Date(year, month, 1)
'Number of Days from the start of the month until the day
'we are looking for.
Dim nextOccurance As Integer = day - myDate.DayOfWeek
If nextOccurance < 0 Then nextOccurance += 7
'Return number of occurances in month
Return Math.Ceiling((Date.DaysInMonth(year, month) - nextOccurance) / 7)
End Function
To use the function:
'Sundays in march 2007
Dim occurences = GetDaysInMonth(2007, 3, DayOfWeek.Sunday)
-- modified at 2:54 Tuesday 13th March, 2007
|
|
|
|
|
hi ur code is nice,
but see i am selecting year and month in dropdownlistbox,
how to pass that value in that function,
i am beginner in this,
so plz help me....
-- modified at 5:35 Tuesday 13th March, 2007
Magi
|
|
|
|
|
ya really nice i got the o/p,
thanks lot,
regards,
Magi
|
|
|
|
|
I am trying to develop a program to execute a .bat file as administrator through vb.net app. I know you need to authenticate and use the system.management class but I am lost on how to do this. Does anyone have an easy way of soing this. Or can someone help me write this way? I would really appreciate it.
Thanks,
Christian
|
|
|
|
|
You can do it under .NET 2.0 using the Process class' ProcessStartInfo[^] class and setting it's Username and Password properties to those of the admin account you want to use.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thanks for the reply but I dont know how to use that either. I am a newbie when it comes to advance vb.net programming. I need more specific instructions. That code gives me an error, saying I need to use a get or set. and an instance is being used before it actually being assigned a value. What ever this means?
|
|
|
|
|
Post the code you're using.
I would also HIGHLY recommend pickly up a book on beginning VB.NET. From what you've described, you're missing the VB.NET 101 basic stuff.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I did find this code..
| Dim instance As ProcessStartInfo
| instance.Password "myPass" 'This is no good because its
System.Security.String
| instance.UserName = "myUser"
-- modified at 15:13 Wednesday 14th March, 2007
|
|
|
|
|
'need to authenticate admin privileges to execute file
'Public Property password() As SecureString
' Get
' End Get
' Set(ByVal value)
' End Set
'End Property
'Dim instance As ProcessStartInfo
'Dim value As SecureString
'value = value.Password
'instance.Password = value
_____________________________________________________________
'this part works but it is only if you have admin privilges
cmd = "\\misfs\public\DST Update\xpdstupdate.exe"
'logon as admin with password to get access to uninstall file
'executes file file on server
Dim startInfo As System.Diagnostics.ProcessStartInfo
Dim pStart As New System.Diagnostics.Process
startInfo = New System.Diagnostics.ProcessStartInfo("cmd")
pStart.StartInfo = startInfo
pStart.Start()
pStart.WaitForExit() 'Your code will halt until the exe file has executed.
|
|
|
|
|
VB.NET 2005:
I want a user to type their nam, then make it so my program recognises when the user presses the enter key (or they can click on the button), then acts as tho a button has been pressed, how would i do this, is it a press down event?
|
|
|
|
|
Well it is not complicated. You define the procedure as a sub or function what has to be handled when user pushes the enter key. Check this code please.
<code>
' Handle the KeyDown event to determine the type of character entered into the control.
Private Sub textBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) _
Handles textBox1.KeyDown
' Determine whether the keystroke is a number from the top of the keyboard.
If e.KeyCode = 13 Then
Call DoMyTask() ' That must be your procedure or function
End If
End Sub
</code>
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
How do i referance to something like a btn1_Click command?
|
|
|
|
|
Make sure you have a button click event attach to your button then use code some what like this to actuate it.
YourButton_Click(YourButton, New EventArgs)
|
|
|
|
|
Sorted, cheers for your help
|
|
|
|