|
You used the declaration for VB6, which won't work in VB.NET because the type names are now different sizes. By this, I mean that in VB6, a Long is a 32-bit signed integer. In VB.NET, the Long type is a 64-bit signed integer. The declaration should be:
Private Declare Auto Function URLDownloadToFile Lib "urlmon" _
(ByVal pCaller As IntPtr, ByVal szURL As String, ByVal szFileName As String, _
ByVal dwReserved As Integer, ByVal lpfnCB As IntPtr) As Integer
You'll call this with:
Dim returnCode as Integer
returnCode = URLDownloadToFile( IntPtr.Zero, "http://www.whatever.com", "C:\MyDownloadedStuff", 0, IntPtr.Zero )
I don't know if it'll work exactly like this because I haven't tried it...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It may be 3.5 years nearly since this was posted, and it has taken HOURS to find it, but thank you, thank you, thank you. I sort of twigged this was the problem but did not know how to fix it.
|
|
|
|
|
Are there any ways to delete a directory that is NOT empty? (In Vb.Net)
I used System.IO.Directory.Delete, but the directory has to be empty..
|
|
|
|
|
Or are there other ways to delete a folder that is NOT empty as well?
|
|
|
|
|
If your supply the Directory.Delete method with the name of the directory and True, it'll delete everything inside the directory you want to kill off.
System.IO.Directory.Delete("C:\TEMP", True)
will delete C:\Temp and everything inside it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a trouble with Ms.Access. I don't know how to add a new record into the specific table inside the VBA-code enviroment of a form.
For examples:
I need to add a new record into the table called 'tblA'. The work is done inside the code VBA of a form.
please,help me...Thanks so much
|
|
|
|
|
Don't you just use SQL to add a record ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
======================================================
Friend Class LCOtherInfo()
protected ss as string
public sub new(byval x as string)
ss=x
end sub
end class
=====================================================
Dim x As New LCOtherInfo(x)
When i create instance of LCOtherInfo but i has an error,"can't obtain value".
Please tell me the way!!!!!!!!!!!!
|
|
|
|
|
TooLeeDiN wrote:
Dim x As New LCOtherInfo(x)
You need to pass a string in here, you're passing in x, which is also the name of the variable you're trying to create.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Can someone please help me in understanding why this code will not work in visual basic .net 2003 ?
I have generated a text file from an access database and I'm trying to read it with my program so hopefully I can manipulate it and write it back to a file. I am having issues with textfieldparser it doesn't appear to exist. Is there an easy way to do this? A working example with a simply txt file would be wonderful or a very step by step tutorial on a website. Thanks for your time.
[code]
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Dim oFileDlg As New OpenFileDialog
If oFileDlg.ShowDialog() = DialogResult.OK Then
Dim sr As New System.IO.StreamReader(oFileDlg.FileName)
MessageBox.Show(oFileDlg.FileName)
sr.Close()
End If
Dim reader As Microsoft.VisualBasic.FileIO.TextFieldParser
reader = My.Computer.FileSystem.OpenTextFieldParser _
("C:\TestFolder1\test1.txt")
reader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
reader.delimiters = New String() {","}
Dim currentRow As String()
While Not reader.EndOfData
Try
currentRow = reader.ReadFields()
Dim currentField As String
For Each currentField In currentRow
MsgBox(currentField)
Next
Catch ex As System.Text.Parsing.MalformedLineException
MsgBox("Line " & ex.Message & _
"is not valid and will be skipped.")
End Try
End While
End Sub
[/code]
Win32newb
"Programming is like sex, make one mistake and you have to support it for a long time"
|
|
|
|
|
win32newb wrote:
Dim sr As New System.IO.StreamReader(oFileDlg.FileName)
MessageBox.Show(oFileDlg.FileName)
sr.Close()
Do you really want to just open and close it there ?
I would forget this, and just use a normal text file reader, read a line at a time and use the split function on the string class to split by ,.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim oFileDlg As New OpenFileDialog<br />
Dim Somestuff As String<br />
If oFileDlg.ShowDialog() = DialogResult.OK Then<br />
Dim sr As New System.IO.StreamReader(oFileDlg.FileName)<br />
Dim mystring As String<br />
<br />
mystring = sr.ReadToEnd()<br />
Dim objMatches As MatchCollection ' a collection of the matches<br />
Dim objReg As Regex<br />
Dim objMatch As Match<br />
<br />
<br />
<br />
objMatches = objReg.Matches(mystring, "/(0\d-\d\d\d\d-\d\d.{5})(.{29})(.{6})(.{9})(.+)\s+SERVICES: ==METERED==\s+.+LAST READING\s(.*)\s+==NON METERED==\s.+---TYPE---\s(.*)/Um")<br />
<br />
<br />
<br />
<br />
<br />
<br />
Dim I As Integer<br />
For I = 0 To objMatches.Count - 1<br />
Somestuff += objMatches(I).Value<br />
<br />
<br />
<br />
Next I<br />
<br />
sr.Close()<br />
End If<br />
TextBox1.Text = Somestuff<br />
End Sub<br />
End Class<br />
Can you take a look at thisi code please and tell me why the heck TexBox1 always contains " " ?
here is a sample of the text file i'm reading in.
<br />
---ACCOUNT---- ------------NAME------------ CLASS -STATUS- -SERVICE / MAILING ADDRESS--<br />
------------------------------------------------------------------------------------------------------------------------------------<br />
01-0005-00 PHILLIPS & LUCKEY COM ACTIVE 102 Blah<br />
PO BOX 1417 Blah, TX 765671417, B009<br />
<br />
SERVICES: ==METERED==<br />
-SERVICE CODE- TBL ACT ----DESCRIPTION---- SCALE DIALS UNITS METER NO# LAST READ DATE LAST READING<br />
10-WATER 5 Y COMMERCIAL 1.000 7 1.00 56914331 6/05 0<br />
<br />
==NON METERED==<br />
-SERVICE CODE- TBL ACT ----DESCRIPTION----- STEP/QUAN ---AMOUNT--- ---TYPE---<br />
I'm eithter real close to getting this resolved or way way way out in left field
thanks for the help
Win32newb
"Programming is like sex, make one mistake and you have to support it for a long time"
|
|
|
|
|
What does the / at the start of the regex do ?
It looks like your text is multiline, are you setting your regex to work across multiple lines ? It does not look that way to me.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
This was for perl where you type / to indicate a regexpression start. Dang I'm confused of how to port this hahaa. Oh well this is fun learning.
Win32newb
"If I wrote a book like I code. It would be one page thick and contain only one word (DUH!)"
|
|
|
|
|
Search this site for Expresso and download it. Perl regex and .NET regex are different in a number of ways. Expresso will let you type in a regex, and see what it matches, using .NET.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks man I appreciate it. Will do. I'm just now getting into visual basic due to work. And its kickin my butt. If you have any good books to by say one for a beginner then one for the next step in sequence please let me know and I will buy them. I feel bad asking questions but its the only way I know how to learn.
Win32newb
"If I wrote a book like I code. It would be one page thick and contain only one word (DUH!)"
|
|
|
|
|
win32newb wrote:
If you have any good books to by say one for a beginner then one for the next step in sequence please let me know and I will buy them.
I got to be honest here. VB is crap. VB6 was utter crap, VB.NET is marginally better. I use C#, and I answer questions here mostly because I can ( they use the same framework, you see ). I can't really recommend a book, I don't own any VB books myself.
win32newb wrote:
I feel bad asking questions but its the only way I know how to learn.
To learn how to code, I bought 'teach yourself C++ in 24 hours' and asked lots of questions online. These forums are here for you to ask, and everyone who answers, does so of their own free will. No reason to feel bad about needing help, we all needed it at one point, too.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks man I downloaded that expresso program but still having some hang ups.
What I'm trying to parse:
01-0005-00 PHILLIPS & LUCKEY COM ACTIVE 102 BURLESON
PO BOX 1417 ROCKDALE, TX 765671417, B009
SERVICES: ==METERED==
Expression I'm using:
\d\d-\d\d\d\d-\d\d.{5}.{29}.{6}.{9}.+
I can get up to :
01-0005-00 PHILLIPS & LUCKEY COM ACTIVE 102 BURLESON
but then I haven't a clue how to make it read the rest i tried \sSERVICES I tried \n but nothing your help would be appreciated.
I get the following result witht he above expression
Win32newb
"If I wrote a book like I code. It would be one page thick and contain only one word (DUH!)"
|
|
|
|
|
\d{2}-\d{4}-\d{2}.*SERVICES:\s?([\S]*)
This will match ==METERED== in a group, and match the rest before ( no grouping, as you didn't have any ). To make it work I turn on multiline AND single line modes.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
win32newb wrote:
Can someone please help me in understanding why this code will not work in visual basic .net 2003 ?
Because there is no Microsoft.VisualBasic.FileIO namespace in .Net 1.1.
Also, there is no 'My' pseudonamespace in .Net 1.1.
You will have to parse it yourself. If you know there won't be any commas in text fields, you can use String.Split to break it apart, then if the first char of a field is a double quote, you ignore the first and last char of the field. This could also probably be done with RegEx. If there might be commas in the text fields, then you have to be more carefull.
|
|
|
|
|
Thank you this is exactly what I was looking for. No the data will be generated from an access database file with comma delimiters and no valid data will have comma's. This will work perfectly.
Thanks once again. I will write back if i have more questions.
-tony-
Win32newb
"Programming is like sex, make one mistake and you have to support it for a long time"
|
|
|
|
|
I have a matter with Ms.Access. I don't know how to pass the value from one form to another form. Also, I want to set this value to the text-box of the destination form.
For example:
I'd like to transfer the value '5' inside the code VBA of the form 'form1' to the form 'form2'. After moving successfully, I want to show this value in a text-box of the destination form. Please point me to a way of solutions.
Thanks so much...
|
|
|
|
|
Private Sub cmdPassValue_Click()
UserForm2.TextBox1 = Me.TextBox1
End Sub
|
|
|
|
|
Hi my friends, I need some help for syncronizing date and time on terminal with VB.NET.
The idea is set the date and time on the terminal with WinCE. The values are taken of PC.
somebody can help me with this problem?
best regards...
|
|
|
|
|
I have an application which reads values from the registry, now when the app loads, if the values dont exist, I am thrown an exception. Is there any way to stop this exception or to catch it. Or can i perhaps make a function or use a Try statement?
|
|
|
|