|
I want to preserve the linefeeds from the RichTextBox to the file I'm writing to the disk drive.
I can see the line feeds in Debug before I write the file, but after writing, there gone.
I suspect it's the method I wrote to write the file.
Using fileStream As New FileStream(m_path, FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite)
Dim htmlLen As Long = htmlText.Length
Dim fileData As Byte() = Encoding.UTF8.GetBytes(htmlText)
fileStream.Write(fileData, 0, htmlLen)
End Using
21st Century Globalism has become Socialism on a planetary scale, in which the unequal treaties of the past have come back into play.
|
|
|
|
|
That took some thinking for me, first time I've done this. Changed over to StreamWriter for this
Using streamWriter As New StreamWriter(m_path, False, Encoding.UTF8)
Dim charArray As Char() = htmlText.ToCharArray()
Dim charLine As Char() = New Char() {}
For cdx As Integer = 0 To charArray.Length - 1
If Not (charArray(cdx) = Chr(10) Or charArray(cdx) = Chr(13)) Then
Array.Resize(charLine, charLine.Length + 1)
charLine(charLine.Length - 1) = charArray(cdx)
Else
Dim newLine As Char() = charLine
streamWriter.WriteLine(newLine)
Array.Resize(charLine, 0)
cdx += 1
End If
Next
streamWriter.Close()
End Using
21st Century Globalism has become Socialism on a planetary scale, in which the unequal treaties of the past have come back into play.
|
|
|
|
|
This is a side cash project, that FoxPro stuff I've been working on and the last bit of code before I ship it today.
I made a dialog box with a Web browser and richtextbox that you can paste HTML into, so it can be injected into an email.
Made the contextMenu with cut, copy and paste, and the event handlers ...
So I can paste from Visual Studio, Word, but not browsers. In the clip board data, I get the StartHTML and EndHTML stuff.
I see some examples in c# for it, custom classes that parse the clipboard, but not anything in VB.
Just wondering if anyone has some code for this, or something down and dirty. It's just going to be used twice a year.
This is the first time I've ever asked for code, just figured why reinvent the wheel on this.
Private Sub PasteAction(ByVal sender As Object, ByVal e As EventArgs)
If Clipboard.ContainsText(TextDataFormat.Rtf) Then
RichTextBox1.SelectedRtf = Clipboard.GetData(DataFormats.Rtf).ToString
ElseIf Clipboard.ContainsText(TextDataFormat.Html) Then
RichTextBox1.SelectedText = Clipboard.GetText(System.Windows.Forms.TextDataFormat.Html)
ElseIf Clipboard.ContainsText(TextDataFormat.Text) Then
RichTextBox1.SelectedText = Clipboard.GetData(DataFormats.Text).ToString
End If
End Sub
21st Century Globalism has become Socialism on a planetary scale, in which the unequal treaties of the past have come back into play.
|
|
|
|
|
Hi, can anyone provide me with a copy(Original) of Visual Basic 6.0? If anyone has an extra product that hasn't been used and a valid product key, I would like to purchase, if possible. I DO NOT want any pirated software or do I wish to suggest this. I can't find VB6.0 to purchase...
Thanks in advance.
|
|
|
|
|
Why??
Wikipedia quote: Mainstream Support for Microsoft Visual Basic 6.0 ended on March 31, 2005. Extended support ended in March 2008.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Sorry for the late reply, but I have a client that did not want to spend the extra $$$ to pay me to "re-vamp" his project that he paid someone else to write and he wanted some upgrades that the past programmer left him the source code and my newer .net environment would not convert the old stuff. (Without rewriting or "putting a band aide" on his existing source. So, I went with the old VS6 and it worked out for the both of us, even though he still spent just as much...oh well, I tried to reason with him. Thanks for asking why...lol
|
|
|
|
|
|
I found a new VS6 package for $20, thanks! It all worked out...
|
|
|
|
|
Hello everyone, we are currently doing a school prototype. we made a notification device and we want to ensure that it is returned properly. There is an arduino inside the device so it is possible to connect it to a pc via usb port. The problem is that we don't know how visual basic will know what serial port is used when the device is connected. We want to use the information on what serial port is used as an input data to operate our magnetic locks. Please help us. Thanks in advance
|
|
|
|
|
|
If you have an USB-Device which creates a virtual COM-Port you could get this Information out of the Registry of your PC.
For example you could search for the Vendor-ID and look for the Sub-Information. Here you will find the actual used COM-Port (if this Device is connected) and perhaps other useful Information.
If you are interested I could look for a sample-code for this.
But you should know, that the Registry-Entries could change by different Operating-Systems.
|
|
|
|
|
Using Win 7 / Winforms / VS 2013 / VB.net
My application stores the last several visited directories in the File menu. But when I click an item in the drop-down to set the .InitialDirectory property the OpenFileDialog just goes back to the last directory viewed. I don't need to store a specific file name, I just need the dialog to open in the desired directory. I've checked the text of the menu items and it's all correct. I also tried hard-coding a directory name and it still goes back to the first directory opened during the session. Code is below:
ofd.InitialDirectory = e.ClickedItem.Text
cntxMenu.Close()
res = ofd.ShowDialog
If res = Windows.Forms.DialogResult.OK Then
PopulateListview(ofd.FileName)
End If
Don't know if this is related: This is a ContextMenuStrip that opens when a button is clicked. There are two items with dropdowns. One is a zoom menu that works fine. But with the recent directories menu, I have to close it with cntxMenu.Close() . Otherwise it remains visible on top of the OpenFileDialog .
What am I doing wrong here?
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
I have just tried a test (Windows 10) and it works correctly. I can only suggest you try using your debugger to see what actually happens as the code runs.
|
|
|
|
|
I was pretty much reduced to throwing code at the wall to see what would stick. Setting the dialog's AutoUpgradeEnabled property to True caused it to behave normally. I'll freely admit to having no idea why. But as it's an application strictly for my own use I'm not going to worry over it at this point.
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
I can remember that the path for the InitialDirectory must be written in a special way.
Assuming that the path you give to the Property of the Dialog is existing and correct written but you should look, if the string ends with a "\" or not. Perhaps you should change this.
|
|
|
|
|
Added a backslash to the strings but that didn't do it either. Perhaps there is a bug that causes the OpenFileDialog to not recognize the string if AutoUpgradeEnabled is false. Seems highly unlikely though. I may create a temporary project and see if I can duplicate the problem there. If not then I'll at least know the problem is unique to one project. I have another app that maintains a list of recent files (not directories) and it's been working fine for years.
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
I struggled with the same problem. When I set the AutoUpgradeEnabled to True, it started working better. But I added the below code and it seems to always works now.
Public Class frmSample
Dim openFileDialog1 As New OpenFileDialog()
Dim sTemp As String
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
openFileDialog1.AutoUpgradeEnabled = True
sTemp = "None"
sTemp = OpenDir()
Do Until sTemp <> "None"
Loop
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 0
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
End If
End Sub
Private Function OpenDir() As String
openFileDialog1.InitialDirectory = "C:\Sample Initial Directory"
Return "OpenDir"
End Function
End Class
|
|
|
|
|
Thanks. I ended up doing something similar but that was a couple of years back. I don't remember exactly how I did it. I should have posted the solve here but apparently I didn't think about it. Thanks again.
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
Just to clarify i'm not using crystal reports, just the ordinary reports in Visual Studio,
I know how to link text boxes to a report but how much I link a listview with multiple rows to a report? I know I need to add the listview contents to a dataset but I cannot find any examples online and i'm really struggling, can anyone help please?
Also, can anyone explain the different between Visual Studio Report and Crystal Report? Are their any benefits to using Crystal Reports over the bog standard one?
Many Thanks
|
|
|
|
|
RedRocket2016 wrote: I know how to link text boxes to a report but how much I link a listview with multiple rows to a report? Usually one puts data from a dataset in the listview, as well as in the report, as opposed to linking a listview directly to a report.
If you can do so for textboxes, then you should be able to do it with a listview. Just fetch the values from the listview and pass them like you would for a textbox.
RedRocket2016 wrote: but I cannot find any examples online If you look for this specific scenario, then no, there will not be an example. There are general examples though.
RedRocket2016 wrote: Are their any benefits to using Crystal Reports over the bog standard one? I have not found one yet, but appears to be popular.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi guys, Im just a newbie in vb.net. Just want to ask for help.. Here's my problem. i have a parent form which i call frmKitchen. Inside it, i have a listview and an user control. I want to reload all the items in the listview when something change in my user control. is there any possible way?
here's my sample code
Main form:
Public Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
selectDistOfItem()
getAndDisplaySum()
Me.Refresh()
End Sub
User control:
Private Sub lvOrders_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvOrders.DoubleClick
If lvOrders.SelectedItems.Count > 0 Then
Dim kit As New frmKitchen
kit.btnRefresh_Click(Nothing, Nothing)
End If
End Sub
I cant reload the data from database to listview when an event done in my user control. please help.. thanks in advance..
|
|
|
|
|
Create an event in your UserControl to signal that any subscriber that the selection in your control changed. The parent form should subscribe to this event so it can get notified when to reload the ListView control with new data.
Google for "VB.NET create an event[^]".
|
|
|
|
|
Hello everyone, I just want to ask for guide to where I'm doing wrong to my codes. My codes is basically to produce reports dynamically after results from database. I'm using vbnet 2015.
Sub Fill()
cryRpt.Load("C:\Users\MicroboxMac\Documents\Visual Studio 2015\Projects\ReportsDemo\ReportsDemo\bin\Debug\cr1.rpt")
cryRpt.SetDataSource(reportsQuery(TextBox1.Text.Trim))
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
End Sub
This the table I'm getting the data results
Public Function reportsQuery(ByVal bId As Integer)
Dim db = New database
Dim dt As New DataTable
MessageBox.Show(bId)
With db
.sqlStr = "SELECT * from brandnames Where brandid = '" & bId & "' " 'query string
.sqlDa.SelectCommand = .sqlcm(.sqlStr, .connect) 'execute command
.sqlDa.Fill(.sqlDt) 'get results and store in sqldt
.close()
End With
Return db.sqlDt
End Function
unfortunately I'm stuck with this error...
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.
I appreciate the time for helping out.
I got it working now...find the solution from other thread by Joezer BH
Best regards,
Joe
modified 18-Dec-16 22:15pm.
|
|
|
|
|
Hi,
I'm Using Visual Studio 2010 (.net) & Crystal Report 8.5 as Crystal Report Builder. I have a trouble that i can't view two different report in one view and different page.
can u help me ?
Thx
Hermawan
|
|
|
|
|
Can you just generate two reports, then add them as two views in a view group? Or paginate that using a control that supports such.
What framework are you using, ASP.NET, or what?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|