|
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
|
|
|
|
|
I am new to Visual basic. I am taking an intro VB class in college and it is pretty basic. This question is not class related and my instructor wasn't sure how to do this. I was wondering how or if it is possible to call a windows application. I would like to call a command prompt so I could code something to work with a command promt running nmap. I haven't had much luck googling so anything to point me in the right direction would be appreciated. Thanks...
|
|
|
|
|
look into the documentation on Process and Process.StartInfo.
|
|
|
|
|
Hey everyone.
Can someone please inform me of a way to retrieve the filesize of the file to download before I download it using the My.Computer.Network.DownloadFile
method.
Your input is appreciated.
Tony
|
|
|
|
|
It depends on where the file is comming from. If you're downloading from an HTTP:// or FTP:// address, then no, you can't find out before you get it. If you're downloading from some local server using a drive letter or UNC path (\\server\share\filepath), then yes, you can use the normal File methods to find out how big the file is.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank-you Dave
for your response I was afraid of that becuase it was an http download that I was trying to get a progress bar working for becuase the showui overload was kinda ugly. So I ended up changing it to a web request instead.
I hate being a newbie. Lol I don't know anything yet but I'm learning.
|
|
|
|
|
hello sir u have send me the solution of validating textboxes,given below its working absolutely fine ...
but if i have 100 textboxes then do i have to validate each and everyone by coding 12-15 lines..
i think it will be very tedious....
any shortcut..?
please tell in vb.net
i am working on VS2003.
code i am usung is
Private Sub Textbox1_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles TextBox1.TextChanged
If Val(TextBox1.Text) > 45 Then TextBox1.Text = CStr(0) : MsgBox("Please Enter A Number Between 0 to 45", MsgBoxStyle.Critical)
End Sub
Private Sub Text1_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
Select Case KeyAscii
Case 48 To 57 '0 To 9
Case 8 'Back Space
Case 13 'Enter
Case Else 'Other Keys
KeyAscii = 0
End Select
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
|
|
|
|
|
I didn't give you the code, but the same textChanged event can be assigned to all of your 100 textboxes. So I would suggest that you connect each of your textboxes with that one textChanged event.
The way to do this is:
At the end where you see the Handles key word you have the TextBox1.TextChanged
All you have to do is add:
,TextBox2.TextChanged, TextBox3.TextChanged, ... till you have added all 100 textboxes.
Hope that helps.
Ben
|
|
|
|
|
u want tosay like this....
Private Sub Textbox1_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
what about the other places where textbox1.text is written like textbox1.keypress and if val(textbox1.text) and all such place where only textbox1.validated....
its highly confusing...
Private Sub Textbox1_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
If Val(TextBox1.Text) > 45 Then TextBox1.Text = CStr(0) : MsgBox("Please Enter A Number Between 0 to 45", MsgBoxStyle.Critical)
End Sub
Private Sub Text1box_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
Select Case KeyAscii
Case 48 To 57 '0 To 9
Case 8 'Back Space
Case 13 'Enter
Case Else 'Other Keys
KeyAscii = 0
End Select
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
|
|
|
|
|
Your eventSender is the TextBox
So:
if Val(CType(eventSender, TextBox).Text) > 45 Then CType(eventSender, TextBox).Text = CStr(0) ...
Hope that helps.
Ben
|
|
|
|
|
thanks man..
its working perfectly...
and reduced mah problem alot..
regards..
manni
|
|
|
|
|
I think as a user I would be annoyed if I got a message everytime I typed in a number greater then 45. The way you have it set up I could type in 12 then accidentally hit 3, thus having 123 in the box, and I would get a warning in addition to the value being reset to 0. I think you should just stop the key from being pressed if it will result in to large a value. This way the user can't type in a larger number and you avoid the warning and clearing the value simply because I hit an extra character on my keyboard. Here is the code to handle that.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Char.IsDigit(e.KeyChar) Then
'Key was a digit
Dim txtBox As TextBox = DirectCast(sender, TextBox)
Dim value As Integer
Dim newText As String = txtBox.Text.Remove(txtBox.SelectionStart, txtBox.SelectionLength)
newText = newText.Insert(txtBox.SelectionStart, e.KeyChar.ToString)
'If value of textbox will be greater then 45 ignore key
If Integer.TryParse(newText, value) Then
If value > 45 Then e.Handled = True
End If
ElseIf Not Char.IsControl(e.KeyChar) Then
'Ignore key: It wasn't digit, backspace, enter, or delete
e.Handled = True
End If
End Sub
|
|
|
|
|
Oh, one more thing. The function 'val' returns 0 if the string isn't a number. Remember a user can still copy and paste text into your textbox. If you use val to determine the value a string of letters it will pass because 'val' will return 0 which is less then 45. You should first make sure the text is a number then convert it's value.
|
|
|
|