|
|
I used this in a windows service before. Try it
string MyAppPath = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
|
i have data of employee and wants to print all emp data with picture
|
|
|
|
|
Although I do not use Crystal Reports these days again, because I use RDLC reports within Visual Studio.
When I was using Crystal Report in those days, I know they also have field for Image (blob), you can use this to print the picture of the employees.
In RDLC reports that I now use, I did something like that and each staff's picture comes out on the pay slip.
What you can do is to add an image/blob field to your employee table and capture their picture with their basic details at employee information setup, which you can link when reporting. Some people may want to save employee pictures on physical disk, this will be rowdy to me and it is not very safe.
Try image/Blob field in your table and when saving the picture, convert it to bytes. It will be shown in Crystal Report or RDLC, just ensure you bind the column to Crystal Report Blob/Image field.
|
|
|
|
|
|
Hi to all, I need to write inside a file located in a folder of my account in google drive and I wrote a desktop application in VB.net using Google Driver API v3. Since that me and my friend use the same account in different PC with the same VB.net application that I wrote, I need your help to to check if that file is opened by another user to avoid opening and garantee an "exclusive opening" on it.
I dont' know if google drive as an option to set an "exclusive opening" instead of API.
Maybe I can set permission to "read only" on the file when is opened by my application but I think it is not a good thing because if my application crashes (for example for a blackout) my file remain in read only state for always.
That's my routine that make a connection on my Google drive with my credentials, search for my folder and my file and give me back their ID:
Public Sub GoogleDrive()
Dim credential As UserCredential
Dim ID_Folder As String = ""
Dim ID_File As String = ""
Using Stream = New FileStream("credenzials.json", FileMode.Open, FileAccess.Read)
'The file token.json stores the user's access and refresh tokens, and is created
'automatically when the authorization flow completes for the first time.
Dim credPath As String = "token.json"
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(Stream).Secrets,
Scopes,
"user",
CancellationToken.None,
New FileDataStore(credPath, True)).Result
Console.WriteLine("Credential file saved to: " + credPath)
End Using
'Create Drive API service.
Dim Service = New DriveService(New BaseClientService.Initializer() With
{
.HttpClientInitializer = credential,
.ApplicationName = ApplicationName
})
' Define parameters of request.
Try
Dim findrequest As FilesResource.ListRequest = Service.Files.List()
findrequest.PageSize = 10
findrequest.Fields = "nextPageToken, files(id, name)"
findrequest.Spaces = "drive"
Dim listFolder As Data.FileList = findrequest.Execute()
If listFolder.Files.Count > 0 Then
For Each item In listFolder.Files
If item.MimeType = "application/vnd.google-apps.folder" Then
If item.Name = "MyFolder" Then
ID_Folder = item.Id.ToString
End If
End If
'
If item.MimeType = "application/msaccess" Then
If item.Name = "myFile.mdb" Then
ID_File = item.Id.ToString
End If
End If
If (ID_File <> "") And (ID_Folder <> "") Then
'How check if ID_File is opened by an other user ?
Exit For
End If
Next
End If
Catch ex As Exception
'MsgBox(ex.Message)
Throw ex
End Try
End Sub
Can someone help me ?
|
|
|
|
|
hello everyone how are you, as always asking for your great help that you have given me, it happens that I have a text document, where I can look for information in a text file, if it finds it, assign that value found in a variable to me format of the text that I have is this, the text document contains several names
Example
Text file
aof.zip:Art Of Fighting / Ryuuko no Ken
Search: aof.zip once finder save in a variable the name that is after the :
Show: Art Of Fighting / Ryuuko no Ken
|
|
|
|
|
|
Hey guy, if you are using VB, it has a function called Instr. This function compares the two strings and returns integer value. If the value returned is greater than 0, that means that is the starting position of the word you are searching for, otherwise it will return -1 if not found.
Note:- Ensure you convert the two strings to the same case before comparing(Upper or Lower case characters).
|
|
|
|
|
Either you're using VB6, which has been dead for over 20 years now...
... or you're still using the VB6-compatibility methods in VB.NET code, which is a recipe for poor performance and ugly code.
Also, InStr returns 0 when a match is not found, not -1 .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Of course I stopped using VB like 5 or 6 years ago, but the person that needs help posted it under VB. I use C# and the approach is different in C#.
You answer questions in the context of where it is posted. I will not use C# to answer VB questions, everyone has his own reasons for choosing a language. For the returned value in search string, I used VB last in 2016 or 2017 and I indicated I was not sure what it would return, but either 0 or -1 to indicate it was not contained in the search string.
As we speak, some companies have huge applications they developed in VB6 and they are a major source of income to their companies, are they going to throw them away because we now have Dot Net Core? That will be crazy! So we help to provide solutions in their context.
|
|
|
|
|
There's nothing in the question to indicate that they're using VB6 rather than VB.NET; unless otherwise specified, it's safest to assume the OP is not using a dead language.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Instr function is not specific to VB6, it is also in VB.Net, perhaps you don't know and secondly you should check the forum title. The forum title where we are discussing is Visual Basic, so the reason I suggested VB function to them.
|
|
|
|
|
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?
|
|
|
|