|
As I said previously, InStr in VB.NET is a VB6-compatability method. Any VB.NET code written in the last twenty years (as opposed to code migrated from VB6) should be using the far superior methods available on the String class[^].
And just because there aren't separate "VB.NET" and "VB6" forums doesn't mean we should assume all questions posted here refer to a language which has been dead for two decades.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi sir,
I managed to connect my ftp folder using this code :
Dim reqFTP As FtpWebRequest = Nothing
reqFTP = DirectCast(WebRequest.Create("ftp://localhost/DRIVER.bat"), FtpWebRequest)
reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails
reqFTP.Credentials = New NetworkCredential("printer", "abc123")
Dim response = DirectCast(reqFTP.GetResponse(), FtpWebResponse)
Dim responseStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(responseStream)
Console.WriteLine(reader.ReadToEnd())
Console.Read()
My question is how to run my .bat file inside the ftp folder?
Hope anyone can help me, tq very much
|
|
|
|
|
Assuming you want to execute the batch file on the client where your code is running, you'll need to download it to a file and then execute it.
Using responseStream As Stream = response.GetResponseStream()
Using fileStream As String = System.IO.File.Create("C:\Path\to\your\file.bat")
responseStream.CopyTo(fileStream)
End Using
End Using
System.Diagnostics.Process.Start("C:\Path\to\your\file.bat")
NB: If you were hoping to execute the file on the server, then you're out of luck. FTP does not provide a mechanism to execute files; it is only used to transfer files between computers.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you sir for your help, i will try it. Tq
|
|
|
|
|
SHAHROL AZMI BIN AMZAT wrote: I managed to connect my ftp folder using this code o you found some code due to Google.
SHAHROL AZMI BIN AMZAT wrote: My question is how to run my .bat file inside the ftp folder? Mhuahaha
No.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
who convert image to matrix using visual basic
|
|
|
|
|
Without considerably more detail, that question makes no sense.
|
|
|
|
|
AA matrix is a 2d object so it needs to be a grayscale image. And usually, it is most convenient to do a byte[,] msatrix since its already on that form.
|
|
|
|
|
I do not code for a living, and infrequently use VB.net under Visual Studio.
When starting a new project, the statup up form name is Form1 in vb.net (this is under VS 2022 community).
If I leave the form name as Form1, then no problems when I build the project. But it seems (and this could be user error on my part), if I change the form name to something else like frmMain, then when I build the project, VS provides compiler errors such as:
Error BC30420 'Sub Main' was not found in 'ModuleTest2.frmMain'
or
Warning BC40046 class 'frmMain' and partial class 'frmMain' conflict in namespace 'Moduletest', but are being merged because one of them is declared partial.
So apparently I am doing something wrong but it seems to me that changing the first form name to something other than Form1 should not cause such a fuss.
Input?
|
|
|
|
|
You are probably changing it outside of Visual Studio. If you right click on the form name in Solution Explorer in Visual Studio and select "Rename", then VS will change all the other references to that name correctly.
|
|
|
|
|
How are you "changing the name" - might sound like a silly question but you'd be surprised at some of the things I've seen
Edit: And when - as in "immediately" or have you already written code that refers to it?
|
|
|
|
|
Using Visual Studio Community 2022 17.1.1
1) Select Visual Basic/desktop/windows form/.NET 6
project opens with Form1 as default
no code, no changes, Build Solution, compiles with no errors
2) Select Visual Basic/desktop/windows form/.NET 6
project opens with Form1 as default
using the Properties window, change the name of Form1 to frmMain, save all files
no code, no other changes
Build Solution = BC30451 'Form1' is not declared. It may be inaccessible due to its protection level
So the question is, if I change the name of a form, do I need to do something else such that VS/VB will "update" everything to acknowledge Form1 has been renamed frmMain?
|
|
|
|
|
Nope. You do not use the Properties window to change the name of a form.
Usually, you either click on the file with the form name and hit F2 to change the name of the file (which VS will happily change the name of the class for you to go along with it), or you click on the class name and hit F2 to rename the class (and all of it's other locations.)
|
|
|
|
|
Unfortunately, when I create a new project, let Form1 come up and then click on Form1.vb under Solution Explorer, click on Form1.vb, press F2, rename Form1 to frmMain, and then build, results in exactly the same build error.
modified 9-Mar-22 14:50pm.
|
|
|
|
|
Well, something's going on that isn't normal.
You can try to get around it by double-clicking "My Project" in Solution Explorer, click the Application tab, then find the "Startup object" dropdown. Click on that and find the name of your startup form and click it, then recompile.
Are there any updates to Visual Studio and Windows that haven't been installed yet?
|
|
|
|
|
"Well, something's going on that isn't normal."
and hence the title of the post.
Going to the application tab and selecting Form1 as the startup object, compiling, and then changing the form name in Solution Explorer allowed compilation without an error.
However, I will note that after changing the form name from Form1 to frmMain as above, in the application tab/startup object, it is still "Form1" and not "frmMain". And while the form name in Solution Explorer is "frmMain", when you click on the form and look at Properties, it is still "Form1"
My Win10 pc and VS are both up to date.
Now here is where it gets even more interesting. Once again start a new project, VB/windows form/desktop/,NET 6, let the solution come up with Form1. Go to Project, Add form, and add a new form. At this time you can call it "frmMain" when it is added. Then go to Solution Explorer, select Form1 and delete it. So at this point, Form1 is gone, and only frmMain remains. Go to application tab/startup and select frmMain as the startup object. Build the solution and then you get:
Error BC30456 'Form1' is not a member of 'test6'.
Now VS is throwing errors on a "form" that has been deleted from the solution.
So I know there are work arounds, but the (somewhat rhetorical) question is: why doesn't VS automatically update all references in the solution when a form's name is changed/deleted?
modified 9-Mar-22 20:22pm.
|
|
|
|
|
Something is broken. I'd try uninstall VS and .NET 6 and reinstalling.
|
|
|
|
|
I gave you the answer yesterday; did you try it?
|
|
|
|
|
Yes I did.
Following the same steps, create a desktop VB windows form .NET 6 project, let the project come up with the standard Form1, then right click on Form1.vb in Solution Explorer, rename as frmMain.vb results in the same error message when you build it after the name change.
|
|
|
|
|
I have used that method on numerous occasions but never had a problem. I suggest you report it to Microsoft.
|
|
|
|
|
Try renaming Form1 before changing the Startup in the project properties.
OR------------------------------
I have also added a form under the form name I wanted (Like Title), again doing this before changing the Startup in the project properties, Save the project exit VS, open VS and load the project. When you go back to Project the drop-down should show the form you added. Select it, return to Solution Explorer and then delete Form1 properties or at least Exclude it from the project.
Both of these have worked for me.
ed
|
|
|
|
|
hi
i need program in visual basic 6 to draw a tooth of spur gear using involute and trochoid curve
|
|
|
|
|
OK, so you're writing this app?
This is not a "for hire" site.
|
|
|
|
|
Can I suggest that you do it in something else other than VB6. Literally anything else. Most people who used to code in VB6 are now long retired - much like that software.
|
|
|
|
|
It is not possible to use anything other than Visual Basic because my graduation project requires drawing in Vb 6
|
|
|
|