|
thank you that has fixed the issue only now i need to tackle the next error:
Conversion from string "." to type 'Double' is not valid.
on this line:
My.Computer.FileSystem.WriteAllText("C:\Users\Pete\Desktop\DJ Sync\DJ Sync\test\REQUEST\" + txtITEM.Text, +"." + ".txt", False)
any ideas ?
Regards
Pete
|
|
|
|
|
Yes, it's failing on the second parameter:
, +"." + ".txt", It probably reads as 0 + "." . The second parameter is the stuff that is written to the file. If you omit the first + on that line, you'd be writing "..txt" to the file.
You might want to divide the statement over multiple lines, makes it a bit easier;
Dim sPath as String = String.Format("C:\Users\Pete\Desktop\DJ Sync\DJ Sync\test\REQUEST\{0}.txt", txtITEM.Text)
Dim sContent as String = "Whatever your content is"
My.Computer.FileSystem.WriteAllText(sPath, sContent, False) Bonus points can be earned by using the SpecialFolder enum to fetch the path to the desktop-directory, and Path.Combine to build the path.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
txtITEM.Text, +"." + ".txt", False
What's wrong there ?
You can't have a "+" next to a ","
|
|
|
|
|
I'm just trying to write a HTML text file. I can read text files, but first time writing them.
So I used the StringBuilder to build some HTML
Then I wrote a for loop to convert the stringbuilder to bytes, and then I wrote the BOM and the rest of the HTML as a file using FileStream
So I choose UT8 as the encoding, but I get the error line feed characters are inconsistent in Visual Studio when testing the file.
The original problem is when I write the file the 2nd time, and read it back, I get a BOM error, but I thought perhaps I need to fix the line feed chars first. I'm not really sure what to do here on this.
Dim m_htmlBuilder As New StringBuilder
With m_htmlBuilder
.Append("<div style=""width: " & p_width & "; Height: " & p_height & "; text-align: center; margin: 0px auto; background-color: rgb(28,134,238);"">" & vbCrLf)
.Append(" <span style=""color: rgb(255,255,255); font-size: 1.0em; font-weight: bold; line-height: " & p_height & ";"">" & vbCrLf)
.Append(p_html_name & " is now ready for use" & vbCrLf)
.Append(" </span>" & vbCrLf)
.Append("</div>" & vbCrLf)
End With
Dim m_htmlStream As String = m_htmlBuilder.ToString
Try
Dim htmlLen As Long = m_htmlStream.Length
Dim charArray As Char() = New Char(htmlLen) {}
Dim byteArray() As Byte = New Byte() {}
For cdx As Integer = 0 To htmlLen - 1
charArray(cdx) = m_htmlStream(cdx)
Dim charVal As Char = charArray(cdx)
Array.Resize(byteArray, byteArray.Length + 1)
byteArray(byteArray.Length - 1) = UTF8CharToByte(charVal)
Next
Using htmlStream = New FileStream(p_html_path, FileMode.Create, FileAccess.Write)
Using writer As BinaryWriter = New BinaryWriter(htmlStream, Encoding.UTF8)
Dim [utf8] As Encoding = Encoding.UTF8
Dim preamble As Byte() = [utf8].GetPreamble()
writer.Write(preamble)
writer.Write(byteArray, 0, byteArray.Length - 1)
If Not (writer Is Nothing) Then
writer.Close()
writer.Dispose()
End If
End Using
If Not (htmlStream Is Nothing) Then
htmlStream.Close()
htmlStream.Dispose()
End If
End Using
|
|
|
|
|
Yeah, that's doing it ........how can I put this........ the hard way.
How about using an overload of the StreamWriter class to handle all the crap for you? Oh, and you don't even have to call ToString on the StringBuilder.
Sub Main()
Dim sb As New StringBuilder()
sb.AppendFormat("Some formatted text containing {0} lines..." & Environment.NewLine, 3)
sb.AppendLine("You don't need vbCrLf at the end of every line if you use the ")
sb.AppendLine("AppendLine method of the StringBuilder instead of Append.")
Using fs As New FileStream("C:\Text.txt", FileMode.Create)
Using sw As New StreamWriter(fs, Encoding.UTF8)
sw.Write(sb)
End Using
End Using
End Sub
|
|
|
|
|
I really wanted to make that work, I'll just save it for another day. Just wanted to work with bytes for the experience.
I ended up just using 3 lines of code using textwriter before your post, but switched to your example for 5 lines and UTF8
On the read side I did the same thing in reverse. But I just changed that to the opposite of your example.
Now everything works from start to finish. Just modified everything and tested it 10 different ways.
Well thanks for the KISS, I made something really simple complex.
|
|
|
|
|
I'm writing a program in VB.NET and try to save different profiles via the application settings (project settings -> settings tab).
I created a Profile class and a collection class of that. If I choose this collection as settings type, I can add multiple objects with type System.Object, but I need to add my Profile object.
How can I add a collection of my Profile objects with the settings editor? Whats wrong with my code?
Profile.vb
Imports System.Configuration
<SettingsSerializeAs(Configuration.SettingsSerializeAs.Xml)> _
Public Class Profile
Public Property Name As String
Public Property ViewerCommand As String
Public Property ViewerPath As String
Public Property StartService As Boolean
Public Property StopService As Boolean
End Class
<SettingsSerializeAs(Configuration.SettingsSerializeAs.Xml)> _
Public Class ProfileCollection
Inherits CollectionBase
Public Shadows Function Add(ByVal ProfileObject As Profile) As Profile
MyBase.List.Add(ProfileObject)
Return ProfileObject
End Function
Public Shadows Sub Remove(ByVal ProfileObject As Profile)
MyBase.List.Remove(ProfileObject)
End Sub
End Class
A screenshot of the current behavior
The type is VNC_Manager.ProfileCollection for the setting called "Profiles".
http://i.stack.imgur.com/4Oaf8.png[^]
On the right side there should be Name, ViewerCommand, ...
If I use VNC_Manager.Profile for type, I also can't see Name, ViewerCommand... So there seems to be a problem with the Profile class(?)
|
|
|
|
|
|
vb.net code for convert a wav file to mp3 file
|
|
|
|
|
If you're looking for someone to write this code for you, you've come to the wrong place.
If you're looking for example code, type the text from your post into Google and start reading. This is what is called "research".
|
|
|
|
|
Yeah, Google it with your favourite search engine (see the lounge postings for ideas).
|
|
|
|
|
Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
multidimensional hierarchy is needed for my report ............. please help me .
my query is like below
SHAPE {SELECT * FROM job_table WHERE job_id = ?} AS parentCMD APPEND ({SELECT *
FROM ((job_table AS p INNER JOIN
job_team AS jt ON p.job_id = jt.job_id) INNER JOIN
Team_Member AS tm ON jt.Member_ID = tm.Member_ID)} AS childCMD RELATE 'job_id' TO 'p.job_id') AS childCMD,({SELECT *
FROM (job_table AS jobTBL INNER JOIN
job_tjb AS jt ON jobTBL.job_id = jt.job_id)} AS tjbCMD RELATE 'job_id' TO 'jobTBL.job_id') AS tjbCMD
|
|
|
|
|
Upgrade to a programming language that is less than 10 years out of date?
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
|
If you provide a code sample of what you've done, you are much more likely to receive assistance.
Simply asking someone to do the work for you if unlikely to produce any positive results.
|
|
|
|
|
There are a million and 1 ways to do this. Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Down vote countered - I was going to be a little more cutting in my remarks to the OP.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
So... you ask for help. People advise you to provide what you've done... and you insult them?
Not a good way to get help...
|
|
|
|
|
|
I don't know what you were expecting. All you did was post your assignment but none of the work you've already done. At no point did you say anything about what problem you were having. Without that, it's impossible to help with any accuracy or clarity.
We will help with the code you're having a problem with IF you prove you've done some work and are stuck.
We will NOT do your work for you.
|
|
|
|
|
I will forever be in your gratitude if you do this
|
|
|
|
|
WHAT DID I JUST TELL YOU???
WE WILL NOT DO YOUR WORK FOR YOU!
It is set that way for a reason. The industry has too many idiot programmers who couldn't debug their way out of a paper bag and you want us to add to that pool?!?!
Doing your work for you doesn't teach you a damn thing!
Sorry, but you just failed your class.
|
|
|
|
|