|
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.
|
|
|
|
|
Hi Dave,
Thanks for your reply and sorry for posting query without proper details. Please help me, how to split a text file in to small files based on the below conditions. At the time of splitting the file should not split in between a record.
For example:- fileSize=1050 bytes
MaxSize=200 bytes
Min size=100 bytes.
After splitting the file into small files based on above max and min sizes.
The files sizes should be as follows.
file1:-200 bytes
file2:-200 bytes
file3:-200 bytes
file4:-200 bytes
After 4 iterations the original file size reduced to 250 bytes, Now the size of the last file should not more than maxsize (i.e 200 in this example) and should not less than minsize(100).
So remaining file sizes shoould be as follows :
file5:- 100 bytes
file6:- 150 bytes.
leave about my logic, what I have posted above, in some cases it wroking and in somecases it is not workin properly. Please tell me the logic.
The failing conditions.
1. if(filesize- (maxsize+minsize) < minsize ) and
example:- Original filesize:- 1050 bytes
maxsize:- 450 bytes
minsize:- 350 bytes
2. maxsize-minsize < minsize
example:- filesize:- 1050 bytes
maxsize :- 125 bytes
minsize :- 100 bytes
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
sudhakar79 wrote: some cases it is failing.
What cases, and in what way are they failing?
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks for your reply and sorry for posting query without proper details. Please help me, how to split a text file in to small files based on the below conditions. At the time of splitting the file should not split in between a record.
For example:- fileSize=1050 bytes
MaxSize=200 bytes
Min size=100 bytes.
After splitting the file into small files based on above max and min sizes.
The files sizes should be as follows.
file1:-200 bytes
file2:-200 bytes
file3:-200 bytes
file4:-200 bytes
After 4 iterations the original file size reduced to 250 bytes, Now the size of the last file should not more than maxsize (i.e 200 in this example) and should not less than minsize(100).
So remaining file sizes shoould be as follows :
file5:- 100 bytes
file6:- 150 bytes.
leave about my logic, what I have posted above, in some cases it wroking and in somecases it is not workin properly. Please tell me the logic.
The failing conditions.
1. if(filesize- (maxsize+minsize) < minsize ) and
example:- Original filesize:- 1050 bytes
maxsize:- 450 bytes
minsize:- 350 bytes
2. maxsize-minsize < minsize
example:- filesize:- 1050 bytes
maxsize :- 125 bytes
minsize :- 100 bytes
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
What you have to do is to make a preliminary list of file sizes, and make corrections to it until it's correct. Set the sizes to the max size, then correct the sizes that are smaller than the min size until there are none left, or until you realise that it's impossible.
For the first example (450 - 350):
450, 450, 150
As the last size is smaller than 350, take bytes from the second file:
450, 250, 350
As the second file is smaller than 350, take bytes from the first file:
350, 350, 350
For the second example (125 - 100):
125, 125, 125, 125, 125, 125, 125, 125, 50
As the last size is smaller than 100, take bytes from the 8th file:
125, 125, 125, 125, 125, 125, 125, 75, 100
As the 8th file is smaller than 100, take bytes from the 7th file:
125, 125, 125, 125, 125, 125, 100, 100, 100
For an impossible example (450 - 400):
450, 450, 150
As the last file is smaller than 400, take bytes from the second file:
450, 200, 400
As the second file is smaller than 400, take bytes from the first file:
250, 400, 400
As the first file is smaller than 400, there is no possible combination of file sizes.
---
single minded; short sighted; long gone;
|
|
|
|
|