|
Unfortunately, I'm building the datagridview rows from reading in a text file.
Your idea about adding a hidden sort column is brilliant!
Thanks Dave.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
I am having trouble finding documentation on how to, using Vb.net to read a png file into a string and convert to Hex.
Dow anyone have any code examples for me? Thank you
|
|
|
|
|
What do you mean by "reading a png file into a string and convert to Hex"??
Any file is just a stream of byte values, 0x00 thru 0xFF. Converting those to Hex is as easy as using String.Format("{0:X2}", value) to return a single value as a Hex string. What you do with those strings is up to you.
|
|
|
|
|
I am reading the png like this. (I don't know if this is the best way.
Dim ascii() As Byte = File.ReadAllBytes("C:\3604.png")
I want to put This into a string.
dim str as string = String.Format("{0:X2}", ascii) Does not work.
Is there an easy way besides looping through each byte and copying it to string?
|
|
|
|
|
Cory Kimble wrote: dim str as string = String.Format("{0:X2}", ascii) Does not work.
Sure it does, when you convert each and every byte in the array, individually. You can't send an array to Format and expect it to iterate over the array for you.
Cory Kimble wrote: Is there an easy way besides looping through each byte and copying it to string?
Nope. That's the only method you have.
|
|
|
|
|
Hi,
I wotre years ago in vb6 a database for music. I want to convert the whole program into VB.net 2008.
The original program was with cddb from gracenote.
The question now is is there support for .net by gracenote or is there something beter/easyer but with the same functions?
Like seeing what cds is in the drive, editing mp3 tags
If posible also support for DVD(music/films/series)
Jan
some examples from the new system are welcome
|
|
|
|
|
There's a GPL service called FreeDB[^] now.
|
|
|
|
|
What must I download?
I think the server software but thats only in C
Jan
|
|
|
|
|
Hi,
I am trying to add a 3rd party dll(C++) to my application which is created on vb.net. when i tried to add that dll as reference i got a error as "A reference to <file location=""> could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
When i checked this in online, it seems to be unmanged code which is not accepted by .net and also they said P/Invoke command something like that.
But actually i dont know how to register a dll or use Pinvoke method or how i add a unmanged dll into my application, Can anyone help in this.
Thanks,
Nanda
|
|
|
|
|
Register a dll using regsvr32.exe. Do you know the functions exported by the dll?
|
|
|
|
|
Thanks JZ, But again.
how to do that with regsrv32.exe, for example my dll name is nanda.dll, where i have to do this and how and what was the output
Thanks,
Nanda
|
|
|
|
|
REGSVR32 filename.dll
But, if the .DLL is not COM-based, this wont work and you'll be forced to use P/Invoke to call the functions in the .DLL. You will not be able to set a reference to it and have VS import the functions for you.
|
|
|
|
|
Thanks Dave,
I tried but It throws a message box
<dll> was loaded, but the DllRegisterServer entry point was not found.
This file can not be registered.
I hope this dll is not com based
Can you please help me how to use P/Invoke with an example.
Thanks,
Nanda
|
|
|
|
|
You got that error because the .DLL is not COM-based. You'll have to use P/Invoke to get at the functions in that library. I hope you have the documentation on it.
http://www.pinvoke.net[^] has tons of examples.
|
|
|
|
|
Hi
I created store produce to insert selected values from checkboxlist into sql database and it gives me this error "Procedure or function SaveAdmin has too many arguments specified."
here is my store procedure
ALTER PROCEDURE [dbo].[SaveAdmin]
-- Add the parameters for the stored procedure here
@Perno int,
@Client_id int,
@Region_id int,
@Service_id int
AS
INSERT INTO Admin(Perno, Client_id, Region_id, Service_id)
VALUES(@Perno, @Client_id, @Region_id, @Service_id)
and here is my vb.net code
cmdStandby.CommandText = "SaveAdmin"
cmdStandby.CommandType = CommandType.StoredProcedure
cmdStandby.Connection = sqlstandby
cmdStandby.Parameters.AddWithValue("@Perno", lblEmpNo.Text)
cmdStandby.Parameters.AddWithValue("@Client_id", ddlClient1.SelectedValue)
For Each li In ChkRegion.Items
If li.Selected = True Then
cmdStandby.Parameters.AddWithValue("@Region_id", li.Value)
End If
Next
For Each li In ChkService.Items
If li.Selected = True Then
cmdStandby.Parameters.AddWithValue("@Service_id", li.Value)
End If
Next
cmdStandby.ExecuteNonQuery()
thanx in advance
Mamphekgo
|
|
|
|
|
Hi, I have never used add with value but I assume it adds the parameter to the collection as well as adding the value. Try using .value =
Even if that worked you would still only get one 'set'passed through as your loops are replacing the value each iteration. Your executenonquery needs to be inside the loop, and the loop needs to add each type of value to the set.
Looking at what you are trying to do I suspect that you should be normalising the database a bit more, unless you want each row to contain the employee and client data for each service ID and region ID
Sort of like: (I don't think this is quite right as I an not sure what you controls are but you should get the idea)
cmdStandby.CommandText = "SaveAdmin"
cmdStandby.CommandType = CommandType.StoredProcedure
cmdStandby.Connection = sqlstandby
cmdStandby.Parameters.Add("@Perno", SqlDbType.Int)
cmdStandby.Parameters.Add("@Client_id", SqlDbType.Int)
cmdStandby.Parameters.Add("@Region_id", SqlDbType.Int)
cmdStandby.Parameters.Add("@Service_id", SqlDbType.Int)
For Each li In ChkRegion.CheckedItems
cmdStandby.Parameters("@Perno").Value = CINT(lblEmpNo.Text) 'or the proper conversion
cmdStandby.Parameters("@Client_id").Value = ddlClient1.SelectedValue 'or should this be selected index? If value what is it ? Text, integer etc
cmdStandby.Parameters("@Region_id").Value = li.Value '(?)
cmdStandby.Parameters("@Service_id").Value = li.Value '(?)
cmdStandby.ExecuteNonQuery()
Next
For Each li In ChkService.CheckedItems
cmdStandby.Parameters("@Perno").Value = CINT(lblEmpNo.Text) 'or the proper conversion
cmdStandby.Parameters("@Client_id").Value = ddlClient1.SelectedValue
cmdStandby.Parameters("@Region_id").Value = li.Value '(?)
cmdStandby.Parameters("@Service_id").Value = li.Value '(?)
cmdStandby.ExecuteNonQuery()
Next
|
|
|
|
|
Is suspect your problem is here:
For Each li In ChkService.Items
If li.Selected = True Then
cmdStandby.Parameters.AddWithValue("@Service_id", li.Value)
End If
Next
This loop is going through a list and checking if it's selected. For each value selected you're adding another parameter (with the same name) to the Parameters collection. If there is more than one item selected, your code is adding more than the 4 parameters to the SQL call.
|
|
|
|
|
hi,
Is there any free activex component that support secure ftp?
|
|
|
|
|
|
Does anyone knows how to share the value of a particular variable but are declared in different class?
|
|
|
|
|
declare the variable as shered variable so it can be accessed and modified. For example
Public Class Utility<br />
Public Shared SharedVariable As Integer<br />
End Class
hope this helps
|
|
|
|
|
Use a property
Dim strVar As String = "la la la"
Public Property SharedMyVariableWithTheWorld() As String
Get
Return strVar
End Get
Set(ByVal value As String)
strVar = value
End Set
End Property
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
No no no, not how to do it!
I can drag and drop lines between list boxes no problem either as a move or a copy and I have got it to check that the item does not exist in the target box BUT.....
Where I am stuck is that if I drag a line, and drop it in the SAME box, it checks that it is there and does nothing EXCEPT if it is a move, rather than a copy, the line has already been removed from the source box.
The boxes are in separate child forms (of the same type) in a MDI comtainer. Looking at the properties of sender it gives the handle - which actually would be useful - if I could get at it. If I can see this information by hovering over the sender, why can I not get at it with intellisense?
Does any one have any ideas how (otherwise) I can differential between the source and target list boxes?
What I find a bit strange is that the list still seems to contain the string being dragged, even though it was removed in the MouseMove routine.
If (e.Effect = DragDropEffects.Copy Or e.Effect = DragDropEffects.Move) Then
'See if the name is already in the list
If lstCollection.FindStringExact(item) = ListBox.NoMatches Then
'The font does not exist in the list
If (indexOfItemUnderMouseToDrop <> ListBox.NoMatches) Then
'There is something under the mouse so insert
Me.lstCollection.Items.Insert(indexOfItemUnderMouseToDrop, item)
Else
'There is nothing under the mouse so add
Me.lstCollection.Items.Add(item)
End If
End If
End If
This is where it is removed
' If the drag operation was a move then remove the item.
If (dropEffect = DragDropEffects.Move) Then
lstCollection.Items.RemoveAt(indexOfItemUnderMouseToDrag)
' Select the previous item in the list as long as the list has an item.
If (indexOfItemUnderMouseToDrag > 0) Then
lstCollection.SelectedIndex = indexOfItemUnderMouseToDrag - 1
ElseIf (lstCollection.Items.Count > 0) Then
' Selects the first item.
lstCollection.SelectedIndex = 0
End If
End If
Thanks
David
|
|
|
|
|
Hello,
You can try out this code. I have used two Listboxes on a form.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 0 To 19
Me.ListBox1.Items.Add("Item " & (i + 1).ToString)
Next
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
Try
ListBox1.DoDragDrop(ListBox1.SelectedItem, DragDropEffects.Copy)
Catch ex As Exception
MsgBox("Drag Error: " & ex.Message)
End Try
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
ListBox2.Items.Add(e.Data.GetData(DataFormats.Text))
End Sub
Private Sub ListBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragEnter
If e.Data.GetDataPresent(DataFormats.Text) Then
e.Effect = DragDropEffects.Copy
Else
MessageBox.Show("No Text Present")
e.Effect = DragDropEffects.None
End If
End Sub
I believe this should assist you.
Regards
Sumit Gupta
|
|
|
|
|
Hi Sumit, thanks for responding but it is not quite what I am trying to determine. I already have code that deals with that. What I need to know is how to identify which list box is the source and which is the target, bearing in mind that they are on different forms which are both identical children of the MDI parent.
David
|
|
|
|