|
What does the code look like that wrote the file?? Maybe it's not really Unicode where you think it is.
Or, there's another possilibity. Change the ReadAllText line to:
Imports System.Io
Imports System.Text
.
.
.
str = File.ReadAllText(direct, Encoding.Unicode)
|
|
|
|
|
Thanks alot. It works.. But need to manipulate the working of normal File.ReadAllText(direct) and File.ReadAllText(direct, Encoding.Unicode)...
thanks a lot once again
|
|
|
|
|
how do i make a array and fill the listview1.groups.addrange(arrayname) with the array?
i want to add groups this way so i can sort the array and add the groups name in the right order: A-Z
i dont have a lot experience with arrays.
thanks for your help!
|
|
|
|
|
If you don't know anything about arrays, I highly suggest picking up a book on VB.NET and going through it. Without this basic knowledge, you're going to find most projects impossible to do.
Dim groupNames(2) As String
groupNames(0) = "Group2"
groupNames(1) = "Group3"
groupNames(2) = "Group1"
Array.Sort(groupNames)
For Each groupName As String In groupNames
ListView1.Groups.Add(New ListViewGroup(groupName))
Next
I've kept this example very simple. There's another method for creating a ListViewGroup array, that can be used with AddRange, that uses an Array's ConvertAll method, but you have to supply a Converter delegate and method to do the conversion from String to a ListViewGroup object. But, if you don't know arrays, this litte topic will not make any sense at all...
|
|
|
|
|
hi thanks four your reply
I do understand how arrays work but i dont know witch type and how i script them.
the code does not work
my code:
Dim groupNames(2) As String<br />
groupNames(0) = "Group2"<br />
groupNames(1) = "Group3"<br />
groupNames(2) = "Group1"<br />
<br />
Array.Sort(groupNames)<br />
' ListView1.Groups.Add("Group1", "Group1")<br />
For Each groupName As String In groupNames<br />
ListView1.Groups.Add(New ListViewGroup(groupName))<br />
Next<br />
ListView1.Items.Add("Item1", 0).Group = ListView1.Groups("Group1")<br />
ListView1.Items.Add("Item2", 0).Group = ListView1.Groups("Group2")<br />
ListView1.Items.Add("Item3", 0).Group = ListView1.Groups("Group3")<br />
End Sub
|
|
|
|
|
svanheest wrote: the code does not work
Define "does not work". What DOES happen?? Do you get an error message??
Is your code running on Windows XP or above? Did you EnableVisualStyles in your project?
|
|
|
|
|
thanks for your reply,
sorry for the bad explanation
im using xp sp2 with vb.net 2005 wit visual styles enabled
listview propertys:
Groups = true
Style = tiles
press a button with this code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim groupNames(2) As String<br />
groupNames(0) = "Group2"<br />
groupNames(1) = "Group3"<br />
groupNames(2) = "Group1"<br />
<br />
Array.Sort(groupNames)<br />
' ListView1.Groups.Add("Group1", "Group1")<br />
For Each groupName As String In groupNames<br />
ListView1.Groups.Add(New ListViewGroup(groupName))<br />
Next<br />
ListView1.Items.Add("Item1", 0).Group = ListView1.Groups("Group1")<br />
ListView1.Items.Add("Item2", 0).Group = ListView1.Groups("Group2")<br />
ListView1.Items.Add("Item3", 0).Group = ListView1.Groups("Group3")<br />
End Sub
i get a group "Default" with item1, item2, item3 in it.
the other groups: group1, group2, group3 does not show in the listview
thx
|
|
|
|
|
Change the group creation code to add a Name to each group:
For Each groupName As String In groupNames
Dim lvg As New ListViewGroup(groupName)
lvg.Name = groupName
ListView1.Groups.Add(lvg)
Next
|
|
|
|
|
hi,
i want to generate a report for a project which will show all the methods or functions called from starting to end.
i.e suppose there is a web applicatioon project and this report should show the flow of the code. (i.e. starting from a button_click event to the database call along with all the methods being called)
so that when a new person will see, s/he able to know the flow of code quickly.
please help me if you have any solution to achive this
Santosh Kumar Maharana
|
|
|
|
|
There are packages that do this already, such as DevPartner[^].
|
|
|
|
|
You're treading in the waters of the ASP.NET forum. Your question really has nothing to do with VB.NET.
But, yes, a cookie that expires in a short time would do this. Ask this question in the ASP.NET Forum for more info.
|
|
|
|
|
Funny I did the same reply in the ASP.NET forum
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I have One Dataset with table name ="table1" having Columns
FileName = Name of file
File Type = Extension of File
File = Binary Data.
After Adding Binary in the Dataset. I generate XML from it by using DS.writeXML("c:\temp\abc.xml")
Now when I need to restore the file it creates the file but on opening the file says it is corrupt or it shows junk data ?
Any GuideLines ???
|
|
|
|
|
You are storing XML (which is plain text) into a binary blob field in your database. I suggest using varchar(max) in SQL 2005 or a text blob field for storage which should sort out your problem.
|
|
|
|
|
Please read my Message Again.. There is no SQL Server. Only Data moving to and fro in XML only.
|
|
|
|
|
Apologies. Trying to do too many things at once...
I assume you are reading the file with dataset.readxml, if not please post back. Otherwise can you provide an example of the content of the xml file which is causing the problem?
Thanks
|
|
|
|
|
The easiest way to do it would be to convert the binary data in the file to a Base64 string, store that in your field, then save the data out to the XML file. Convert.ToBase64String[^]
Keep in mind, XML was NOT designed to be a database. It's purpose is to pass messages between systems. Storing binary data in an XML file can result in VERY large files. Just something to think about...
|
|
|
|
|
Hello,
I have a datagridview which contains a combo box column (Status) with these values (To be ordered, Ordered, Delivered)
Then the user click on the combo box and selects Delivered, i want an event to fire so I can capture and compare what the user has selected. What is the best event to use?
My design is like this:
IF(cell is changed to "Delivered") Then
'Then do something
ELSE
'Do nothing
END IF
Also, the datagrid is bound to a binding source.
Many thanks for any suggestions or code,
Steve
|
|
|
|
|
Hello,
This is my code using the cellValidating event
Private Sub dgvPendingOrders_CellValidating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles dgvPendingOrders.CellValidating<br />
Dim status As String = Me.dgvPendingOrders.CurrentRow.Cells("StatusPending").Value<br />
<br />
If (status = "Delivered") Then<br />
'Do something<br />
Else<br />
'Do something else<br />
End If<br />
End Sub <br />
I have noticed that because the datagridview is bound to the binding source and the binding source as been filtered to only display "ordered" rows, as soon as i change the combo box to delivered, it disappears from the dgv so it doesn't capture the status.
Any ideas?
Many thanks,
steve
-- modified at 8:56 Friday 13th July, 2007
|
|
|
|
|
i want to program inputbox so if i click ok it's save value in variable or variable = nothing if i click cancel ewven there is value
notes
if i press space button more than once when i press ok button the variable return null value
md_refay
|
|
|
|
|
Hi md,
There are (at least) two ways you can do it:
1. the InputBox:
Dim MyVariable As String = InputBox("Please enter your name: ","Login","first name here")<br />
'code here to validate the input, for example:<br />
Select Case MyVariable<br />
Case "John"<br />
'something happens here<br />
Case "Peter"<br />
'something else happens here<br />
Case Else<br />
'and yet something else entirely happens here<br />
End Select
2. A self made dialog:
First add a new form to your app with a textbox and ok and cancel buttons.
Then in the load event of the form enter:
Your_OK_Button.DialogResult = DialogResult.Yes<br />
Your_Cancel_Button.DialogResult = DialogResult.No
You can then use the events of the textbox to validate input (for example if only spaces were entered)
call the new form using
Dim MyForm As New MySelfMadeDialog<br />
MyForm.ShowDialog<br />
MyVariable = MyForm.TextBox1.Text<br />
MyForm.Dispose<br />
Hope this helps you,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
I'm using a webbrowser in my application.
I'm taking this error when I open second time this form.
How can I solve this problem?
thanx...
Webbee™ the Œ
|
|
|
|
|
Do you have IE7 installed on the machine?? If so, read this thread[^].
|
|
|
|
|
Hi,
Requirement is like, splitting a big text file into small files based on max and min sizes, these max and min sizes, we will pass as orguments to the file splitter function.
the condition is, all the files sizes after splitting should be in between max and min sizes.
Can any one help me out.
Here is my code, but some cases it is failing.
Public Class cFileSplit
'Dim File_size_in_MB As Long = FileLen("C:\Load sub directory\sample.txt")
Dim info As Byte() = New Byte(-1) {}
Dim bytes As Integer = 0
Dim flag As Integer
Dim remainder As Integer = 0
Private Function TextFileSplit(ByVal sFileName As String, ByVal liSize As Long) As Boolean
Dim File_size_in_MB As Long = FileLen(sFileName)
Dim File_size_in_MB1 As Long
Dim iFilecounter As Integer
Dim oFile As File
Dim oFileInfo As FileInfo
Dim tmpOutfilename As String
'Dim sfileout As File
Dim oWrite As StreamWriter
Dim oRead As StreamReader
Dim MaxSize As Long = liSize
Dim MinSize As Long = 100
Dim obj As New cFileSplit
Try
'open the file from the txtFiletoSplit textbox
oFileInfo = New System.IO.FileInfo(sFileName)
tmpOutfilename = oFileInfo.FullName.Replace(oFileInfo.Extension, "").ToString & "_" & iFilecounter.ToString & oFileInfo.Extension
oRead = oFileInfo.OpenText()
oWrite = File.CreateText(tmpOutfilename)
Do While oRead.Peek <> -1
If bytes >= MaxSize AndAlso flag = 1 Then
oWrite.Flush()
oWrite.Close()
iFilecounter += 1
bytes = 0
File_size_in_MB = File_size_in_MB - MaxSize
'set the new filename
tmpOutfilename = oFileInfo.FullName.Replace(oFileInfo.Extension, "").ToString & "_" & iFilecounter.ToString & oFileInfo.Extension
'open the new file
oWrite = File.CreateText(tmpOutfilename)
ElseIf bytes >= MinSize AndAlso flag = 2 Then
oWrite.Flush()
oWrite.Close()
iFilecounter += 1
bytes = 0
File_size_in_MB = File_size_in_MB - MinSize
flag = 3
'set the new filename
tmpOutfilename = oFileInfo.FullName.Replace(oFileInfo.Extension, "").ToString & "_" & iFilecounter.ToString & oFileInfo.Extension
'open the new file
oWrite = File.CreateText(tmpOutfilename)
ElseIf bytes >= File_size_in_MB AndAlso flag = 4 Then
oWrite.Flush()
oWrite.Close()
iFilecounter += 1
bytes = 0
File_size_in_MB = 0
'set the new filename
tmpOutfilename = oFileInfo.FullName.Replace(oFileInfo.Extension, "").ToString & "_" & iFilecounter.ToString & oFileInfo.Extension
'open the new file
oWrite = File.CreateText(tmpOutfilename)
End If
'Write a line to the file from the file we are reading
'While File_size_in_MB > MaxSize
If File_size_in_MB > MinSize Then
If File_size_in_MB - MaxSize > MinSize Then
Dim lsline1 As String = oRead.ReadLine()
oWrite.Flush()
oWrite.Write(lsline1)
oWrite.WriteLine()
info = New UTF8Encoding(True).GetBytes(lsline1)
bytes = bytes + info.Length
flag = 1
Else
If File_size_in_MB - MinSize >= MinSize Then
Dim lsline2 As String = oRead.ReadLine()
oWrite.Flush()
oWrite.Write(lsline2)
oWrite.WriteLine()
info = New UTF8Encoding(True).GetBytes(lsline2)
bytes = bytes + info.Length
flag = 2
If File_size_in_MB > MinSize AndAlso flag = 3 Then
Dim lsline3 As String = oRead.ReadLine()
oWrite.Flush()
oWrite.Write(lsline3)
oWrite.WriteLine()
info = New UTF8Encoding(True).GetBytes(lsline3)
bytes = bytes + info.Length
flag = 4
End If
Else
If File_size_in_MB > MinSize Then
Dim lsline3 As String = oRead.ReadLine()
oWrite.Flush()
oWrite.Write(lsline3)
oWrite.WriteLine()
info = New UTF8Encoding(True).GetBytes(lsline3)
bytes = bytes + info.Length
flag = 4
End If
End If
End If
End If
Loop
Catch ex As Exception
Throw ex
Finally
'now close all the open files
oWrite.Flush()
oWrite.Close()
oRead.Close()
oWrite = Nothing
oRead = Nothing
oFile = Nothing
oFileInfo = Nothing
End Try
Return True
End Function
Public Shared Sub Main()
Dim obj As New cFileSplit
obj.TextFileSplit("C:\Load sub directory\sample.txt", 200)
End Sub
End Class
End Namespace
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
I'm not reading all this code and you haven't told us what the problem is, other than "it doesn't work". An explanation of the problem would help narrow this down.
|
|
|
|