visual basic
19 TopicsSpecify locale/language for exception messages to user during runtime.
I am using VB 2022 with .NET 8 & 9. I develop applications that allow the user to specify which language they want the GUI elements to be displayed in while the application is running - regardless of what language the users' MS Windows profile is set to. The reason I do this is because some companies (mine included) require all systems to be set to the U.S. English (EN-US) regional/locale settings. This is very easy for me to achieve, even for expected user errors which I can head off. However, unexpected system error messages are always displayed in the English language because the system is set to the English language. Is there any known way to force unexpected error/exception messages to be displayed in a language other than the system's current language? If I knew every single possible error that could be thrown up, as well as its corresponding error code/number, I could create translations myself. But, unfortunately, I have no way of listing every possible system error that could be thrown up during runtime. It would be nice if Microsoft had a COMPLETE list of these somewhere. But every list I've seen is fragmented and incomplete, and sometimes doesn't include a corresponding error code with the message. Try 'Attempt the following block of code. '/////////////////////////////////////////////// ' E X E C U T E S O M E C O D E H E R E ! '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Catch e As System.Exception 'Trap any unexpected system error. MessageBox.Show(e.HResult.ToString & NewLine & e.Message, MyCaption, MessageBoxButtons.OK, MessageBoxIcon.Error) 'Display the error message to the user. End Try Even though the user's system is set to the English language, I want to be able to display the message passed in the 'e.Message' member from the codes sample in whatever language the user has specified their GUI to display in during that application's runtime. Any ideas how to achieve this? BTW... the ability to do this would be an AWESOME feature for Microsoft to add to future .NET releases.118Views0likes0CommentsBurke Learns Blazor - Let's build the API!
This summer, Burke and Jon are porting theurlist.com to Blazor - a real world JavaScript application written in Vue.js. Join them each week as they use Visual Studio, Visual Studio Code and GitHub Copilot to rebuild this app and try to tackle every frontend issue you might encounter along the way. Now that we've got a working Blazor Static Web App with GitHub CI / CD and Azure deployment figured out, it's time to get that API going. Plus, Burke reveals how he conquered his fear of clowns. Community Links: https://www.theurlist.com/burke-learns-blazor Featuring: Jon Galloway (@jongalloway), Burke Holland (@burkeholland) #Beginner #Blazor #Web464Views1like0CommentsExtract images from excel stored as Place in cell
Hello experts, I am trying to extract images from an Excel file using a C# program. My code successfully retrieves images that are placed over cells in the worksheet. Now, I need to adapt this functionality so that it can retrieve images which are stored as Place in cell in the excel .I want use this Azure Function for Business Central integration here is the code using Openize.Cells; using System.IO; using DocumentFormat.OpenXml; class Program { static void Main(string[] args) { string filePath = "C:\\Users\\Raj.Kamal\\Downloads\\test.xlsx"; // The path to your workbook string outputDirectory = "C:\\Users\\Raj.Kamal\\Downloads"; // Load the workbook from the specified file path Workbook wb = new Workbook(filePath); // Select the first worksheet from the workbook var worksheet = wb.Worksheets[0]; // Extract images from the worksheet var images = worksheet.ExtractImages(); // Check if the output directory exists; if not, create it if (!Directory.Exists(outputDirectory)) { Directory.CreateDirectory(outputDirectory); } // Loop through each extracted image foreach (var image in images) { // Construct a unique file path for the image using a GUID var outputFilePath = Path.Combine(outputDirectory, $"Image_{Guid.NewGuid()}.{image.Extension}"); // Save the image data to the constructed file path using (var fileStream = File.Create(outputFilePath)) { image.Data.CopyTo(fileStream); } } } } Any code snippets, documentation links, or best practices would be greatly appreciated. Excel file:277Views0likes0Commentscannot plot vertical aligned column range in chart.net
Hi I need to plot 10 column range vertical aligned. With this code I have compensate disalignment BUT after 4 plot it become again disaligned: Me.Invoke(Sub() Chart.Series("FOOT").Points.AddXY(Indice_Corrente, Dato_Base_FOOT, Dato_Plot_FOOT) Chart.Series("SX_UP").Points.AddXY(Indice_Corrente - 0.65, Dato_Base_SX_UP, Dato_Plot_SX_UP) Chart.Series("SX_DOWN").Points.AddXY(Indice_Corrente - 1.3, Dato_Base_SX_DOWN, Dato_Plot_SX_DOWN) End Sub) Why????????183Views0likes0CommentsVisual Basic Script Problems with Excel
Hello, I'm having trouble writing a script in Visual basic with the help of ChatGPT. for some reason it adds an email in the first cell of the table and i have no idea why. ChatGPT cant fix it unfortunately. The script is supposed to take information out of an excel file and use that to compile an email and sent it from outlook. This is my script: Sub Planning_script() Dim OutlookApp As Object Dim OutlookMail As Object Dim ExcelApp As Object Dim Sheet As Object Dim LastRow As Integer Dim Row As Integer Dim Name As String Dim email As String Dim WeekHours As String Dim JobFunction As String Dim Content As String Dim timeZone As String Dim value As Variant Dim kleur As Variant ' Maak een nieuw Outlook-object Set OutlookApp = CreateObject("Outlook.Application") ' Open het huidige spreadsheet Set ExcelApp = CreateObject("Excel.Application") ExcelApp.Visible = False ' Voorkomt dat Excel zichtbaar wordt Set Sheet = ExcelApp.Workbooks.Open("C:\Wesley\Planning2.xlsx").Sheets("Planning2") ' Verander het pad naar je bestand en de naam van het blad ' Stel de juiste tijdzone in timeZone = "Europe/Amsterdam" ' Bepaal het aantal rijen in het werkblad LastRow = Sheet.Cells(Sheet.Rows.Count, "A").End(-4162).Row ' -4162 betekent xlUp ' Loop door elke rij in het werkblad, beginnend bij rij 2 (rij 1 zijn de koppen) For Row = 2 To LastRow Name = Sheet.Cells(Row, 1).value ' De naam staat in de eerste kolom (kolom A) email = Sheet.Cells(Row, 2).value ' Het e-mailadres staat in de tweede kolom (kolom B) WeekHours = Sheet.Cells(Row, 27).value ' Haal de totale weekuren op uit kolom AA JobFunction = Sheet.Cells(Row, 28).value ' Haal de functie op uit kolom AB ' Maak een HTML-tabel met de inhoud van de planning voor de huidige persoon Content = "<h2>Planning</h2>" Content = Content & "<h3>Rooster voor " & Name & "</h3>" Content = Content & "<table border='1'>" ' Loop door elke dag van de week en voeg waarden toe aan de HTML-tabel Content = Content & "<tr><th colspan='4'>Maandag</th><th colspan='4'>Dinsdag</th><th colspan='4'>Woensdag</th></tr>" Content = Content & "<tr><th>Begin</th><th>Eind</th><th>Pauze</th><th>Totaal</th><th>Begin</th><th>Eind</th><th>Pauze</th><th>Totaal</th><th>Begin</th><th>Eind</th><th>Pauze</th><th>Totaal</th></tr>" Content = Content & "<tr>" For j = 2 To 13 ' Loop through each day of the week (Monday, Tuesday, Wednesday) value = Sheet.Cells(Row, j).value kleur = Sheet.Cells(Row, j).Interior.Color ' Haal de kleur van de achtergrond op voor deze cel If IsDate(value) Then value = Format(value, "HH:mm") ' Zet de waarde om naar een leesbare tijd End If ' Voeg de waarde en achtergrondkleur toe aan de cel in de tabel Content = Content & "<td style='background-color:" & RGB(kleur Mod 256, kleur \ 256 Mod 256, kleur \ 65536 Mod 256) & "; height: 23.5px'>" & value & "</td>" Next j Content = Content & "</tr>" Content = Content & "</tr><tr><td colspan='12' style='height: 10px; font-size: 1px; line-height: 0; padding: 0; margin: 0;'><br></td></tr>" Content = Content & "</tr>" ' Voeg de tweede set kolommen toe voor donderdag, vrijdag en zaterdag Content = Content & "<tr><th colspan='4'>Donderdag</th><th colspan='4'>Vrijdag</th><th colspan='4'>Zaterdag</th></tr>" Content = Content & "<tr><th>Begin</th><th>Eind</th><th>Pauze</th><th>Totaal</th><th>Begin</th><th>Eind</th><th>Pauze</th><th>Totaal</th><th>Begin</th><th>Eind</th><th>Pauze</th><th>Totaal</th></tr>" Content = Content & "<tr>" For j = 14 To 25 ' Loop through each day of the week (Thursday, Friday, Saturday) value = Sheet.Cells(Row, j).value kleur = Sheet.Cells(Row, j).Interior.Color ' Haal de kleur van de achtergrond op voor deze cel If IsDate(value) Then value = Format(value, "HH:mm") ' Zet de waarde om naar een leesbare tijd End If ' Voeg de waarde en achtergrondkleur toe aan de cel in de tabel Content = Content & "<td style='background-color:" & RGB(kleur Mod 256, kleur \ 256 Mod 256, kleur \ 65536 Mod 256) & "; height: 23.5px'>" & value & "</td>" Next j Content = Content & "</tr>" ' Voeg de totale weekuren en functie toe onder de planning Content = Content & "<tr><th colspan='6'>Werkuren deze Week</th><th colspan='6'>Functie</th></tr>" Content = Content & "<tr></tr>" ' Totaal Weekuren en Functie Content = Content & "<tr><td colspan='6' style='vertical-align: middle; text-align: center;'>" & WeekHours & "</td><td colspan='6' style='vertical-align: middle; text-align: center;'>" & JobFunction & "</td></tr>" Content = Content & "</table>" ' Verstuur de e-mail alleen als het e-mailadres geldig is If email <> "" Then Set OutlookMail = OutlookApp.CreateItem(0) ' 0 betekent een nieuw e-mailbericht With OutlookMail .To = email .Subject = "Jouw rooster" .HTMLBody = Content ' Verstuur de e-mail .Display ' Toon het e-mailbericht in de conceptenmap van Outlook End With Set OutlookMail = Nothing End If Next Row ' Sluit het Excel-bestand ExcelApp.Quit Set ExcelApp = Nothing End Sub This is my excel file: When i run the script (or macro) i get this result: As you can it randomly adds their mail to the first cell. If anyone could help me with this the i'd greatly appreciate it. thanks in advance! NikolinoDE mtarler HansVogelaarSolved523Views0likes2CommentsVisual Basic .Net - Consume webservice soap with certificate
Hello: I have created a windows forms project. I have added the service that I have to consume. I need to create code in order to consume it using certificate. Partial code that I have from a documentation is follwowing (web service reference is called "ClientServeiDeutesProves"): Try Dim servei As New ClientServeiDeutesProves.DeutesServiceClient Dim deutes As ClientServeiDeutesProves.Deutes = New ClientServeiDeutesProves.Deutes() deutes.Codi = txtIN.Text deutes.DNINIFContribuent = txtDNI.Text deutes.Idioma = txtIdioma.Text System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12 Dim result As ClientServeiDeutesProves.DocumentResult Try result = servei.GenerarDocument (deutes) Catch ex As System.ServiceModel.FaultException(Of ClientServeiDeutesProves.DeutesFault) MessageBox.Show(ex.Detail.Codi + " - " + ex.Detail.Descripcio) Return End Try 'Resposta If result Is Nothing Then MessageBox.Show("No s'ha obtingut resposta") Return End If If result.TeDeutes Then MessageBox.Show("Té deutes") Else MessageBox.Show("No té deutes") End If If result.Document Is Nothing Then MessageBox.Show("No s'ha pogut obtenir el document") Else MessageBox.Show("Document guardat a c:\temp\docudeutes.pdf") IO.File.WriteAllBytes("c:\temp\docudeutes.pdf", result.Document) End If Catch ex As Exception MessageBox.Show(ex.Message + vbCrLf + ex.InnerException.Message) Return End Try Anybody knows how to build it? Thank you very much. Francesc355Views0likes0CommentsSubject: Help & Support Case for System.GUID value & case sensitivity (Capital letter & Low letter)
Help & Support Case From, Abhay Sakunde, Cognizant India Pvt. Ltd. Pune Project Team: MWS CWS Apps Team E-mail ID: email address removed for privacy reasons email address removed for privacy reasons Mobile No.: (phone number removed for privacy) To, The Manager, Human Resources Or Development Team, Microsoft India Pvt. Ltd. Pune Subject: Help & Support Case for System.GUID value & case sensitivity (Capital letter & Low letter) Hi Team, In case of Microsoft SQL Server Database GUID value gets stored with case sensitivity. But if same value retrieved from database into .NET data grid view then that value is not case sensitive. So, can it be made case sensitive? Waiting for reply. Please let me know if any detail information required for mentioned feature. Screens: [1] Application ID Field with GUID Value Thanks & Regards, Abhay Sakunde506Views0likes1CommentSubject: Help & Support Case for data grid view values along with row number.
Help & Support Case From, Abhay Sakunde, Cognizant India Pvt. Ltd. Pune Project Team: MWS CWS Apps Team E-mail ID: mailto:email address removed for privacy reasons mailto:email address removed for privacy reasons Mobile No.: (phone number removed for privacy reasons) To, The Manager, Human Resources Or Development Team, Microsoft India Pvt. Ltd. Pune Subject: Help & Support Case for data grid view values along with row number. Hi Team, In case of Microsoft SQL Server Database Query Editor if select query is run or executed then result gets displayed with row number. But if same result value retrieved from database into .NET data grid view then that row number value doesn’t come. Also, in case of debug mode for data table, row number value doesn’t come. So, can such result be made available with row number? Waiting for reply. Please let me know if any detail information required for mentioned feature. Thanks & Regards, Abhay Sakunde460Views0likes1CommentSubject: Help & Support Case for MS EXCEL File Schema - Issue.
Help & Support Case From, Abhay Sakunde, Cognizant India Pvt. Ltd. Pune Project Team: MWS CWS Apps Team E-mail ID: mailto:email address removed for privacy reasons mailto:email address removed for privacy reasons Mobile No.: (phone number removed for privacy reasons) To, The Manager, Human Resources Or Development Team, Microsoft India Pvt. Ltd. Pune Subject: Help & Support Case for MS EXCEL File Schema - Issue. Hi Team, In case of Microsoft SQL Server Database Query Editor if select query is run or executed then result gets displayed with row number. But if same result value retrieved from database into .NET data grid view then that row number value doesn’t come. Also, in case of debug mode for data table, row number value doesn’t come. So, can such result be made available with row number? Waiting for reply. Please let me know if any detail information required for mentioned feature. Thanks & Regards, Abhay Sakunde704Views0likes1Comment