|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
I'm facing a problem with VB.NET 2022 that I recently installed on my PC. I'm new to programming, so I'd appreciate some guidance on this issue.
The problem I'm encountering is related to the "Windows Form App" template in VB.NET 2022. Here's what's happening:
Initial Launch: When I launch VB.NET 2022 for the first time and create a new project using the "Windows Form App" template, everything works as expected. The form is displayed correctly.
Subsequent Launches: However, if I close VB.NET and reopen it, the "Windows Form App" template seems to be missing. It's not available in the list of project templates. This happens every time I close and reopen VB.NET.
Opening Previous Projects: Additionally, if I try to open a project that I created using the "Windows Form App" template, I encounter an error message.
I'm really eager to learn and get started with programming, so this issue is quite frustrating for me. As a beginner, I would greatly appreciate any assistance or guidance you can provide to help me resolve this problem.
Thank you so much for your time and help!
|
|
|
|
|
ionline4u wrote: if I try to open a project that I created using the "Windows Form App" template, I encounter an error message.
And what does this "error message" tell you?
|
|
|
|
|
i have seen the error message only one time and do not notice about the error.Now the designer is also disapear.I try to retrive the error message but this time the error message is also disapear.
|
|
|
|
|
Why is it every noob thinks the error message isn't important? IT'S THE ONE PIECE OF INFORMATION EVERYONE NEEDS TO TROUBLESHOOT THE PROBLEM!
I would recommend uninstalling Visual Studio and reinstalling it and see if you can get the error message again or it just works after that.
|
|
|
|
|
Because we are experienced we must have seen all error messages, and can guess which one the OP is talking about.
|
|
|
|
|
I assume that you are referring to Visual Studio 2022, as I do not think there is an application named VB.NET 2022. You should check that you have the Visual Basic workload correctly installed - use the "Extensions" -> "Manage Extensions" menu items. Also, check which template you are using: "Windows Forms App"* or "Windows Forms App (.NET Framework)". You can gather further information by examining the folders where your projects are being saved.
*The first of these use the new .NET core versions of the code and framework.
|
|
|
|
|
Generating a small printing program. I have Brother color laser printer that can duplex print. However, when I get the CanDuplex value, it returns False:
pd.PrinterSettings.CanDuplex
The interesting thing is that checking for color capability works just fine:
pd.PrinterSettings.SupportsColor
Accessing the printer via conventional MS Office applications (as well as other applications like Acrobat) has no problem identifying that the printer can print in duplex.
Thoughts?
Pound to fit, paint to match
modified 21-Aug-23 11:37am.
|
|
|
|
|
|
Please I am using VB.net 2019 and Sql 2016 and I have the below codes which inserts the pdf into the database successfully. But retrieving it becomes a problem for me and that is not the case for an image. I want to convert and retrieve this line of code into pdf "Me.Pdf1.Image=Image.fromStream(ms)" which gives an exception because it is not an image but pdf in the database. Please help me. Thank
OpenFileDialog1.ShowDialog()
txtPdfPath.Text = OpenFileDialog1.FileName
Dim ms1 As New MemoryStream
frmBPA1.Pic1.Image.Save(ms1, frmBPA1.Pic1.Image.RawFormat)
SqlQuery = "Insert into BPA1 (Pdf1)Values(@Pdf1)"
com.Parameters.AddWithValue("@Pdf1", ms1.ToArray)
com.CommandText = SqlQuery
com.CommandType = CommandType.Text
SQLCon.Open()
com.ExecuteNonQuery()
SQLCon.Close()
Dim strQuery As String = "Select df1 from BPA1"
SQLCon1.Open()
comFile = New SqlCommand(strQuery, SQLCon1)
comFile.Parameters.AddWithValue("@ReceiptNo", Me.txtReceiptNo.Text.Trim)
daFile = New SqlDataAdapter(comFile)
daFile.Fill(taFile)
If taFile.Rows(0).Item("Pic1") IsNot DBNull.Value Then
Dim img() As Byte
img = taFile.Rows(0).Item("Pdf1")
Dim ms As New MemoryStream(img)
If img.Length <> "0" Then
Me.Pic1.Image = Image.FromStream(ms)
End If
|
|
|
|
|
txtPdfPath.Text = OpenFileDialog1.FileName
That is not uploading anything, OpenFileDialog gets filenamse from the uiser, but it does not read them.
frmBPA1.Pic1.Image.Save(ms1, frmBPA1.Pic1.Image.RawFormat)
SqlQuery = "Insert into BPA1 (Pdf1)Values(@Pdf1)"
You create a memory stream object ms1 from some image data. You then try to save something that you have saved in the variable named Pdf1 , but you have not placed any data in Pdf1 that I can see. And why are you treating a PDF file as image data?
|
|
|
|
|
Thanks for the reply. Please storing the pdf is not a problem but retrieving it is issue for now. Please how do I retrieve this line Me.Pic1.Image = Image.FromStream(ms) and convert it into pdf. This line of code was used to retrieve image file correctly and I used the same process to store a pdf file but the above code to retrieve is it is the problem. Thanks
Dim strQuery As String = "Select ReceiptNo,Pic1 from BPA1 where ReceiptNo=@ReceiptNo"
SQLCon1.Open()
comFile = New SqlCommand(strQuery, SQLCon1)
comFile.Parameters.AddWithValue("@ReceiptNo", Me.txtReceiptNo.Text.Trim)
daFile = New SqlDataAdapter(comFile)
daFile.Fill(taFile)
If taFile.Rows(0).Item("Pic1") IsNot DBNull.Value Then
Dim img() As Byte
img = taFile.Rows(0).Item("Pic1")
Dim ms As New MemoryStream(img)
If img.Length <> "0" Then
Me.Pic1.Image = Image.FromStream(ms)
Else
Me.Pic1.Image = Nothing
End If
End If
|
|
|
|
|
If you cannot retrieve the PDF data then how can you be sure that you have saved it correctly? As I mentioned in my previous response, I cannot see any PDF data being saved.
|
|
|
|
|
That demonstrates a misunderstanding of what a PDF is.
To view an image such as a png you use an image viewer that supports png images. To view a PDF you use a PDF viewer. Those are two different things.
Your thought process should be - first section.
1. Find the file (it does not matter that it is a PDF.)
2. Store the bytes in the file as binary/raw in the database. At this point it is not actually a PDF (and certainly not an image), but rather just binary/raw data.
Second section
1. Load the binary data
2. Handle the binary data as a PDF file. Such as figuring out how to either use a PDF viewer or deferring to something (like browser).
From the above this means that the following code is always going to be wrong. Because it is not an image.
Image.FromStream(ms)
|
|
|
|
|
How to access scanner device in vb?
|
|
|
|
|
This question can only be answered with the documentation of this device and perhaps additional information from the distributer.
|
|
|
|
|
|
<pre>Hi, i am quit new to .net. But this should be easy for you guys
the output of a string is 202205W24 or 202205W1
I want the last digit so 24 or 1 from the string and use those digits as a string</pre>
|
|
|
|
|
|
|
Was the extra 'c' a test for the observant?
|
|
|
|
|
|
|
I've been struggling to send this CURL request in VB.NET and hope someone can help..
Here is a link to the documentation of the exact request I'm trying to send.
This is the sample CURL request:
curl -u 'username:token' 'https://api.dev.name.com/v4/domains' -X POST -H 'Content-Type: application/json' --data '{"domain":{"domainName":"example.org"},"purchasePrice":12.99}'
Here is the code that I put together and tested:
Dim uri As New Uri("https://api.dev.name.com/v4/domains")
Dim myUsername As String = txtUsername.Text.Trim & ":" & txtApiKey.Text.Trim
Dim data As String = "{""domain"":{""domainName"":""example.org""},""purchasePrice"":12.99}"
Dim dataByte As Byte()
request = WebRequest.Create(uri)
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes(myUsername)))
request.ContentType = "application/json"
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
request.Method = "POST"
dataByte = Encoding.UTF8.GetBytes(data)
request.GetRequestStream.Write(dataByte, 0, dataByte.Length)
Dim myResp As HttpWebResponse
myResp = request.GetResponse()
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
WebResponse = myreader.ReadToEnd()
MsgBox(WebResponse)
However, the code above always returns a (400) Bad Request.
Here is another variation of pretty much the same code which I tried:
Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse
Dim myUsername As String = "username:token"
myReq = HttpWebRequest.Create("https://api.dev.name.com/v4/domains")
myReq.Method = "POST"
myReq.ContentType = "application/json"
myReq.Headers.Add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes(myUsername)))
Dim myData As String = "{""domain"":{""domainName"":""example.org""},""purchasePrice"":12.99}"
Dim dataBytes As Byte() = Encoding.UTF8.GetBytes(myData)
myReq.GetRequestStream.Write(dataBytes, 0, dataBytes.Length)
myResp = myReq.GetResponse()
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
WebResponse = myreader.ReadToEnd()
MsgBox(WebResponse)
But, as you can already guess, it also returns a 400 (Bad Request).
|
|
|
|