|
This line If Trim(Sites) = Trim(strSiteCode) Then is supposed to find the matching entry in both Sites and R03sites files ie. BEC , BEC and then process the shortcut creation and write to console if no match is found. Then loop through the rest of the file. I would like to learn how to make it stop when it finds the match but I can't even make it work the way I need it to yet.
|
|
|
|
|
Member 11866893 wrote: Then loop through the rest of the file. I would like to learn how to make it stop
break;
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi folks,
I am new to vb. I need help to create a vb.net windows service to download latest new uploaded files from server after every 1 minute to local computer . This code download same only single file once the service started. BUT I want to windows service detect each latest new file uploaded on server and download it automatically. Below is my code. Kindly help me.
Imports System
Imports System.IO
Imports System.Net
Imports System.Timers
Imports System.Threading
Public Class Service1
Dim timerSchedule As System.Timers.Timer
Protected Overrides Sub OnStart(ByVal args() As String)
' MyThread = New Threading.Thread(AddressOf Execute)
timerSchedule = New System.Timers.Timer(1000)
AddHandler timerSchedule.Elapsed, AddressOf timerSchedule_Elapsed
timerSchedule.Start()
End Sub
Protected Overrides Sub OnStop()
End Sub
Private Sub timerSchedule_Elapsed(ByVal pSender As Object, ByVal pArgs As System.Timers.ElapsedEventArgs)
Try
timerSchedule.Stop()
'call my a function to do the scheduled task
FTPDownloadFile()
Catch ex As Exception
Finally
timerSchedule.Start()
End Try
End Sub
Private Sub FTPDownloadFile()
Dim ftpuri As String = ""
Dim downloadpath As String = ""
Dim ftpusername As String = ""
Dim ftppassword As String = ""
'Create a WebClient.
Dim request As New WebClient()
' Confirm the Network credentials based on the user name and password passed in.
request.Credentials = New NetworkCredential("root", "")
'Read the file data into a Byte array
Dim bytes() As Byte = request.DownloadData("http://localhost/salary_system/")
Try
' Create a FileStream to read the file into
For Each i As String In downloadpath
Dim DownloadStream As FileStream = IO.File.Create("C:\download\*.php")
' Stream this data into the file
DownloadStream.Write(bytes, 0, bytes.Length)
' Close the FileStream
DownloadStream.Close()
Next
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
MsgBox("Process Complete")
End Sub
End Class
|
|
|
|
|
Hi,
Posting the question three times only annoys people.
Have you set "Allow service to interact with the desktop", if not your service may hang on the msgbox's.
|
|
|
|
|
firstly i posted question in another forum, so one member suggested me to post question in vb forum. That's why i posted here. and window service is interacting with desktop. it is working fine only problem is that it is downloading only specif file when the service is started. i want to download each new uploaded file.
I am not trying to annoy people. i have problem. pls help me
|
|
|
|
|
Member 12957775 wrote: suggested me to post question in vb forum
Yes and what else were you told to do? Did you do either one? I would guess not as this is the same code with the exact same problem.
Member 12957775 wrote: i have problem. pls help me
If you don't listen we are just wasting our time.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
|
Hi folks,
I am new to vb. I need help to create a vb.net windows service to download latest new uploaded files from server after every 1 minute to local computer . This code download same only single file once the service started. BUT I want to windows service detect each latest new file uploaded on server and download it automatically. Below is my code. Kindly help me.
Imports System
Imports System.IO
Imports System.Net
Imports System.Timers
Imports System.Threading
Public Class Service1
Dim timerSchedule As System.Timers.Timer
Protected Overrides Sub OnStart(ByVal args() As String)
' MyThread = New Threading.Thread(AddressOf Execute)
timerSchedule = New System.Timers.Timer(1000)
AddHandler timerSchedule.Elapsed, AddressOf timerSchedule_Elapsed
timerSchedule.Start()
End Sub
Protected Overrides Sub OnStop()
End Sub
Private Sub timerSchedule_Elapsed(ByVal pSender As Object, ByVal pArgs As System.Timers.ElapsedEventArgs)
Try
timerSchedule.Stop()
'call my a function to do the scheduled task
FTPDownloadFile()
Catch ex As Exception
Finally
timerSchedule.Start()
End Try
End Sub
Private Sub FTPDownloadFile()
Dim ftpuri As String = ""
Dim downloadpath As String = ""
Dim ftpusername As String = ""
Dim ftppassword As String = ""
'Create a WebClient.
Dim request As New WebClient()
' Confirm the Network credentials based on the user name and password passed in.
request.Credentials = New NetworkCredential("root", "")
'Read the file data into a Byte array
Dim bytes() As Byte = request.DownloadData("http://localhost/salary_system/")
Try
' Create a FileStream to read the file into
For Each i As String In downloadpath
Dim DownloadStream As FileStream = IO.File.Create("C:\download\*.php")
' Stream this data into the file
DownloadStream.Write(bytes, 0, bytes.Length)
' Close the FileStream
DownloadStream.Close()
Next
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
MsgBox("Process Complete")
End Sub
End Class
|
|
|
|
|
Okay, so I have an idea for a little quick addition to a program that I thought could be simple but I cant exactly find any information on it nor confirmation that it is even possible in visual basic.
I am using vb6, but I can also use .net if it this is not possible in vb6.
So here is my question. I have a text box where a number will be inputted from another aspect of the whole program. The inputted text will be 84 characters long. I need a command button to delete the first 46 and last 4 characters. For the grand finale, I need that number to be inverted!
Now, I have racked my brain for weeks on this little debacle and have not come up with anything.
I hope that someone has an idea on what to do with this.
I have also been thinking, I can due without the inverting of the numbers because I'm not sure that is t all possible. Or, if I need to, I can make it into two command buttons.
This is merely an aspect of a larger working program so Id rather not re write this in another language. However, it is also just for fun (hence why I wanted to do it in vb6) so I'm not going to cry if it doesn't work out.
Thanks for any help at all
|
|
|
|
|
Member 12961546 wrote: any help at all
Okay... since you didn't say what you needed help with...
Member 12961546 wrote: I'm not sure that is t all possible
Yes, it is possible. VB6 has a Left, Right and StrReverse functions so I fail to see why you think that this is a problem at all.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
|
In a vb.net 2010 application, I have the following code that works sometimes:
Dim txtOrigAddress As String = _attendanceLetterOrig.Substring(CInt(_attendanceLetterOrig.IndexOf("ADDR_BEG")), _attendanceLetterOrig.IndexOf("ADDR_END") - _attendanceLetterOrig.IndexOf("ADDR_BEG"))
Dim txtOrigAddress As String = _attendanceLetterOrig.Substring(CInt(_attendanceLetterOrig.IndexOf("ADDR_NEXT")),4)
The problem is the folllowing values do not exist:
_attendanceLetterOrig.IndexOf("ADDR_BEG")
_attendanceLetterOrig.IndexOf("ADDR_END")
_attendanceLetterOrig.Substring(CInt"ADDR_NEXT")
What kind of an edit can I use to check if the 3 values listed above actually exist? I want to prevent application errors.
Would you show me the code to see if the values really exist?
|
|
|
|
|
|
If the substring isn't found, IndexOf returns -1 . You'll need to find and store each index first, then check that they're not -1 before calling Substring .
Also, IndexOf already returns an Integer . There's no need to call CInt .
Dim startIndex As Integer = _attendanceLetterOrig.IndexOf("ADDR_BEG")
Dim endIndex As Integer = _attendanceLetterOrig.IndexOf("ADDR_END", startIndex)
If startIndex <> -1 AndAlso endIndex <> -1 Then
Dim txtOrigAddress As String = _attendanceLetterOrig.Substring(startIndex, endIndex - startIndex)
End If
Your second example makes no sense. The IndexOf method returns the index of the start of the matched substring, if found. So _attendanceLetterOrig.IndexOf("ADDR_NEXT") returns the index of "A" , and _attendanceLetterOrig.Substring(..., 4) will always return "ADDR" .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The source code for the menu strip like notepad menu strip.
|
|
|
|
|
Member 12955439 wrote: The source code for the menu strip like notepad menu strip. What about it?
|
|
|
|
|
If you think someone is just going to hand you code you're sorely mistaken.
The only code you're going to get is the code YOU write.
Now, if you have a question I suggest you describe the problem you're having, in detail, and we'll see what see can do.
|
|
|
|
|
i have a app and in this app have a class inherits from datagridview. basically i try to create a datagridview with specific properties and it will be generated automatically as a control of a panel. after program starts, datagridview is created and retrieves some data from database. so far everythings ok.
Public Class grid
Inherits DataGridView
Private _dgv As New DataGridView
Public Property Dgv
Set(value)
_dgv = value
End Set
Get
Return _dgv
End Get
End Property
Public Sub New()
End Sub
Public Sub New(panel As Panel)
_dgv.Name = "dgv"
_dgv.Parent = panel
_dgv.AllowUserToAddRows = False
_dgv.AllowUserToDeleteRows = False
_dgv.ReadOnly = True
_dgv.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
_dgv.Dock = DockStyle.Fill
_dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect
_dgv.DefaultCellStyle.SelectionBackColor = Color.LightGray
_dgv.DefaultCellStyle.SelectionForeColor = Color.Black
_dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
_dgv.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
End Sub
End Class
using panel.controls.add(grid) routine for loading datagridview to panel.
my question is after datagridview generated how to triger cellmousedoubleclick event?
using vb.net 2012.
thanks in advance.
|
|
|
|
|
You can call an event like a method, if you provide the correct arguments.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hi,
I managed. Actually there were more than one problem in my app. This question was just a step 1. But i did it all. I would like to explain how i did it.
The exact thing that i expect from my app is a custom genereted dgw and its celldouble click event firing. after that event happens another form pops up with controls on it and those controls retrieves data from sql server db.
How i did it the codes are below. not good programming i guess. any suggestions?
Public Sub New(panel As Panel)
_dgv.Name = isim
_dgv.Parent = panel
_dgv.AllowUserToAddRows = False
_dgv.AllowUserToDeleteRows = False
_dgv.ReadOnly = True
_dgv.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
_dgv.Dock = DockStyle.Fill
_dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect
_dgv.DefaultCellStyle.SelectionBackColor = Color.LightGray
_dgv.DefaultCellStyle.SelectionForeColor = Color.Black
_dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
_dgv.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
AddHandler _dgv.CellDoubleClick, AddressOf dgvClick
End Sub
Public Sub dgvClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs)
Dim sql As New SQLAraclari
sql.DBDT = Nothing
If e.RowIndex = -1 Then
Return
End If
If isim = "Sifreler" Then
Try
UserID = Convert.ToInt32(Dgv.CurrentRow.Cells(0).Value)
MsgBox(userID.ToString)
Catch ex As Exception
MsgBox(e.ToString)
End Try
sql.SorguyuCalistir("SELECT tblPersoneller.PerID, PerAdi, PerSoyadi, PerKullaniciAdi, PerSifre FROM tblPersoneller JOIN tblPersonelSifreler ON tblPersoneller.PerID = tblPersonelSifreler.PerID WHERE tblPersonelSifreler.PerID = " & UserID & ";")
For Each r As DataRow In sql.DBDT.Rows
frmSifreGir.txtAdi.Text = r("PerAdi")
frmSifreGir.txtSoyadi.Text = r("PerSoyadi")
If String.IsNullOrEmpty(r.Item("PerKullaniciAdi").ToString) Then
frmSifreGir.txtKullaniciAdi.Text = ""
Else
frmSifreGir.txtKullaniciAdi.Text = r("PerKullaniciAdi")
End If
If String.IsNullOrEmpty(r.Item("PerSifre").ToString) Then
frmSifreGir.txtSifre.Text = ""
Else
frmSifreGir.txtSifre.Text = r("PerSifre")
End If
Next
If sql.HataVarmi(True) Then MsgBox(sql.Exception)
frmSifreGir.Show()
ElseIf isim = "Kayitlar" Then
Else
End If
End Sub
|
|
|
|
|
You're creating a new database-object and then checking the rowindex;
If e.RowIndex = -1 Then
Return
End If Would you not want to do that as the first thing in the event? If it is -1, you won't need the database anyway.
I'd also recommend using the IDbConnection/IDbCommand structures to query a database; it is more recognizable and easier to maintain.
..the way it is now, some of our members would blast you for leaving your code vulnerable against SQL-injection.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanks for your advice. I used parameters against sql injection.
|
|
|
|
|
You're welcome
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Dear All
I have a scenario like the folder contains some 7000 file. I have to take 1st 2000 file and 7-zip it then another 2000 files and so on...How can achieve this using vb script. Can any one assist me/
R.Sasikumar
|
|
|
|
|
There's an example on using VB-script to execute a command here[^]. Find the correct parameters for 7zip, and execute it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello All,
How can i embed excel inside the web browser in vb .net please help me in this regard.
Thanks & Regards,
Sampath
|
|
|
|
|
You'll need Excel locally installed if you want to open stuff using it. What have you tried, and what is the problem exactly?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|