|
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;
|
|
|
|
|
Hi friends,
i desprately need a method to do paging a Datalist(ASP.NET), that will be displaying data using SQLDataSource.
Any help?
:- Rashid Ali -:
|
|
|
|
|
You're asking this question in the wrong forum. You're looking for the ASP.NET[^] forum.
|
|
|
|
|
hello frnds,
i am using vb.Net 2.0 , i have developed a application which is add the custom variable and update it.
now , i want to update the variables by
objDoc.customDocumentsProperties("BlahBlah")="BlahBlah"
objDoc.fields.Update()
objDoc.Save()
and all the custom variables are updated EXCEPT the variables under the Header and footer are not gor updated ....WHY??
Where i am wrong ...Please tell
help....
regards,
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Hi,
Currently I am able to drag and drop a single item at a time from a list box to another listbox, but I need to drag multiple items at a time. here is the code for dragging single item. just tell me how I can drag and drop multiple items between list boxes
//////////**************************////////////////////
Public Class Form1
Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
ListBox1.Items.Add(Lsstr1)
End If
End Sub
Private Sub ListBox1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If ListBox1.Items.Count = 0 Then
Return
End If
Dim lsstring As String = ListBox1.Items(ListBox1.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects = DoDragDrop(lsstring, DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox1.Items.RemoveAt(ListBox1.IndexFromPoint(e.X, e.Y))
End If
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
ListBox2.Items.Add(Lsstr1)
End If
End Sub
Private Sub ListBox2_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub ListBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox2.MouseDown
If ListBox2.Items.Count = 0 Then
Return
End If
Dim ls As String = ListBox2.Items(ListBox2.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects = DoDragDrop(ls, DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox2.Items.RemoveAt(ListBox2.IndexFromPoint(e.X, e.Y))
End If
End Sub
End Class
//////////////***********************///////////////////////////
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
You need to change your code in the DragDrop event to cast the data to an array of strings, not just a single string. Then you need to iterate through the strings and add them to the ListBox:
Private Sub ListBox1_DragDrop(blah, blah) Handles ListBox1.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String() = DirectCast(e.Data.GetData(DataFormats.StringFormat), String())
For Each item As String In Lsstr1
ListBox1.Items.Add(item)
Next
End If
End Sub
|
|
|
|
|
Private Sub ListBox1_DragDrop(blah, blah) Handles ListBox1.DragDrop If e.Data.GetDataPresent(DataFormats.StringFormat) Then Dim Lsstr1 As String() = DirectCast(e.Data.GetData(DataFormats.StringFormat), String()) For Each item As String In Lsstr1 ListBox1.Items.Add(item) Next End IfEnd Sub
your logic is not working for multiple selections, if I select and move multiple items from one list box to another list box, there I am able to view only one string 4 times iteration
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
That's because the code is written for strings. I tested it using drag and drop of multiple files from Explorer.
You'll have to modify your code to put the appropriate item types into the Data object and pull those same item types out of the Data object. If you're posting and array of Object items to the drag, you have to pull the same array of Object item types off, not an array of Strings.
Post the code you're using to populate the drag.
|
|
|
|
|
Many many thanks for your interest.
Here is the code where I am passing a string to dodragdrop() function.Please make the needfull changes to this code.
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If ListBox1.Items.Count = 0 Then
Return
End If
Dim lsstring As String = ListBox1.Items(ListBox1.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects =DoDragDrop(lsstring,DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox1.Items.RemoveAt(ListBox1.IndexFromPoint(e.X, e.Y))
End If
End Sub
/************** here is the entire code of sample project************///
Public Class Form1
Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
ListBox1.Items.Add(Lsstr1)
End If
End Sub
Private Sub ListBox1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If ListBox1.Items.Count = 0 Then
Return
End If
Dim lsstring As String = ListBox1.Items(ListBox1.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects = DoDragDrop(lsstring, DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox1.Items.RemoveAt(ListBox1.IndexFromPoint(e.X, e.Y))
End If
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim Lsstr1 As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
ListBox2.Items.Add(Lsstr1)
End If
End Sub
Private Sub ListBox2_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub ListBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox2.MouseDown
If ListBox2.Items.Count = 0 Then
Return
End If
Dim ls As String = ListBox2.Items(ListBox2.IndexFromPoint(e.X, e.Y)).ToString()
Dim lodde1 As DragDropEffects = DoDragDrop(ls, DragDropEffects.All)
If lodde1 = DragDropEffects.All Then
ListBox2.Items.RemoveAt(ListBox2.IndexFromPoint(e.X, e.Y))
End If
End Sub
End Class
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
Ummm...Your're not populating the DragDrop with the strings at all. You're just removing the items from the source list box! There's nothing in the Drop because you didn't put anything into it!
You have to start a Drag and Drop operation by populating the data being transerfered with the ListBox's DoDragDrop[^] method.
|
|
|
|
|
Dim str1 As String
str1 = " "
Dim i As Integer
i = 0
Dim intag As Boolean
intag = False
Dim thetag As String
thetag = " "
Dim htmlinput As String
htmlinput = TextBox1.Text
Dim tempchar As String
Const a As String = "ControlChars.Tab"
For i = 0 To htmlinput.Length() - 1
tempchar = htmlinput.Chars(i)
If (tempchar.Equals("<")) Then
intag = True
thetag = ""
tempchar = ""
ElseIf (tempchar.Equals(">")) Then
intag = False
tempchar = ""
ElseIf (tempchar.Equals(" ")) Then
tempchar = ""
End If
If (intag) Then
thetag += tempchar
ElseIf (thetag.Equals("td")) Then
str1 += tempchar + " "
thetag = ""
ElseIf (thetag.Equals("tr")) Then
str1 += tempchar + " "
thetag = ""
ElseIf (thetag.Equals("\n")) Then
str1 += tempchar
thetag = ""
Else
str1 += tempchar
End If
Next
TextBox2.Text = str1
i have a file txt file with following text
now i want to display the txt file code in another textbox as this is displayed in a html file.
my code at the top has a certain mistake. which i am not able to rectify.
could any one help
there is no such thing as good or bad.
|
|
|
|
|
Why do you think that there is a problem with the code?
What is it supposed to do?
---
single minded; short sighted; long gone;
|
|
|
|
|
Missing Indentation.
|
|
|
|
|