|
The real question is, how do you *expect* 32765 to convert to a color ? If you mean it's an RGB value, you can use int.TryParse to get a number, and bit masking to extract the three values, which you can then turn into a color. So, 32765 && 0xFF, 32765 && 0xFF00, and 32765 && 0xFF0000 will get your three byte values.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You can use the Color.FromArgb method to convert a number to a color. It expects a 32 bit value where there are eight bits each for alpha, red, green and blue.
If the value represents a color without an alpha value, you use FromArgb twice to set the alpha value. Example:
Dim c As Integer = &HFFFF00 'yellow<br />
Dim myColor As Color = Color.FromArgb(255, Color.FromArgb(c))
If your value represents a color in a different way, it may be simpler to extract the color components and create a color from that:
Dim myColor As Color = Color.FromArgb(red, green, blue)
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello,
I know that there are many projects that show how to implement checking the md5 hash of a file in vb6 however I was not able to find any for vb.net can any one point me to the right direction ?
Thanks
Al968
Avast Antivirus-<url>http://www.avast.com<url>
|
|
|
|
|
Md5 is built into the System.Cryptography namespace. Therefore, no-one is going to write sample code to do it, the framework does it already.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you for your responce, I didn't know it was built-in.
Thanks
Al968
Avast Antivirus-<url>http://www.avast.com<url>
|
|
|
|
|
I want to bind data in a Select Statement in a stored procedure in SQL Server 2005 to a GridView
in Visual Basic 2005.
I set the DataSourceID of the GridView to the Stored Procedure and in runtime Bind the Data with
DataBind Method.
But it dose not work.
Please help me.
|
|
|
|
|
It sounds like you have some misconceptions about how all this works. Post the code you're using to get the data and bind the grid and we'll see if we can straighten it out. Is this an ASP.NET app or Windows Forms?
You don't bind to a stored procedure. You call a stored procedure to return the records you want. The records end up in either a DataTable or some other bindable source. You then bind the grid to that record set.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I wrote this code
<asp:gridview id="GridView1" runat="server" allowpaging="True" autogeneratecolumns="False"
="" backcolor="#CCCCCC" bordercolor="#999999" borderstyle="Solid" borderwidth="3px" cellpadding="4" cellspacing="2" forecolor="Black" datasourceid="SQLDS_Select_Project">
<footerstyle backcolor="#CCCCCC">
<columns>
<asp:boundfield datafield="Number" headertext="تعداد">
<asp:boundfield datafield="Model" headertext="مدل">
<asp:boundfield datafield="Heavy" headertext="سنگین">
<asp:boundfield datafield="Kind" headertext="نوع ماشین">
<asp:boundfield datafield="Number_M" headertext="تعداد فعال در پروژه">
<asp:boundfield datafield="Title" headertext="عنوان پروژه">
<asp:boundfield datafield="Row" headertext="ردیف" readonly="True">
<rowstyle backcolor="White">
<selectedrowstyle backcolor="#000099" font-bold="True" forecolor="White">
<pagerstyle backcolor="#CCCCCC" forecolor="Black" horizontalalign="Left">
<headerstyle backcolor="Black" font-bold="True" forecolor="White">
<asp:sqldatasource id="SQLDS_Select_Project" runat="server" connectionstring="<%$ ConnectionStrings:SamanMohitConnectionString %>"
selectcommand="Select_Project" selectcommandtype="StoredProcedure">
<selectparameters>
<asp:parameter defaultvalue="Farsi" name="F_Language" type="String">
and in .aspx.vb i write this code
Protected Sub Page_Load(Parameters)
GridView1.DataBind
End Sub
|
|
|
|
|
What code? This is HTML. There's nothing here that calls any kind of database.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I am have to use Sybase database in my appliction.
Is there any way to use it without installing ODBC Driver on each machine, I mean like is there any way to directly connect to Sybase by imporing a reference dll or something.
Thank you!
"Mess with the Best, Die like the rest"
|
|
|
|
|
Well, you could TRY to use the OleDb methods, but they're not going to support SyBase the best since they're kind of "generic". Other than that, you have no choice but to install the driver, or use a different database, like SQL Server or Access, that comes with the drivers already installed.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If now OleDb wht other choice do i have, since i am using a IVR system that only deployes Sybase as their database.
Thank You!
"Mess with the Best, Die like the rest"
|
|
|
|
|
M. Nauman Yousuf wrote: since i am using a IVR system that only deployes Sybase as their database.
The only other choice you have is to install the drivers.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm trying to create an application where i can browse the Active Directory OU folder structure. I need to select an OU and need the OU name for a next action in the application.
Any help is welcome.
Roland
|
|
|
|
|
|
Already found some information like this below, but it doesn't show any results:
mports System
Imports System.DirectoryServices
Public Class Form1
Class DirLister
Shared Sub Main(ByVal args() As String)
Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://192.168.1.1")
Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.Filter = ("(objectClass=computer)")
Dim resEnt As SearchResult
For Each resEnt In mySearcher.FindAll()
Form1.Text = (resEnt.GetDirectoryEntry().Name.ToString())
Next
End Sub
End Class
|
|
|
|
|
Replace this line :
Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://servername/DC=DCNAME, DC=local")
hopes it helps,
Wachill
Signature has been encrypted
|
|
|
|
|
That didn't work either, i also changed it after your suggestion into:
Imports System
Imports System.DirectoryServices
Public Class Form1
Class DirLister
Shared Sub Main(ByVal args() As String)
Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://mydomain.local/RootDSE")
Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.Filter = ("(objectClass=computer)")
Dim resEnt As SearchResult
For Each resEnt In mySearcher.FindAll()
Form1.Text = (resEnt.GetDirectoryEntry().Name.ToString())
Next
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Do i forgot something? I just want to test this with display the results at my empty form and work from there with the results.
Roland
|
|
|
|
|
Can you tell me what is not working correctly. Is it that you are not getting the required results or that you are getting an error message.
Signature has been encrypted
|
|
|
|
|
Ummm... To be frank, you're copying and pasting code that you don't understand at all, and I'm not talking about the directory searching code. It's this
Form1.Text = blah, blah, blah
in int your Main. The search code may actually be working, but since you put all this in the Main method, before the form even shows on the screen, you'll never see the results. And, the Text property of the Form just changes the TitleBar text. It doesn't show up in the form itself.
Get rid of Main method and move it into the Form_Load event. Add a ListBox to the Form and expand it to cover the form. Then change the code in the Form_Load event:
Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://your AD server/AD path to search")
Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.Filter = "(objectClass=Computer)"
Dim resEnt As SearchResult
For Each resEnt In mySearcher.FindAll()
ListBox1.Items.Add(resEnt.GetDirectoryEntry().Name)
Next
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you, i got it working with your supplied code. Just need some finetuning now, but this is working.
Roland
|
|
|
|
|
I also got i working with a treeview and a OU list. I changed:
ComboBox1.Items.Add(resEnt.GetDirectoryEntry().Name)
into:
TreeView1.Nodes.Add(resEnt.GetDirectoryEntry().Name)
The problem now is that i only see a list of OU's and not into a real treeview.
So i see:
OU1
OU2
OU3
OU1a
OU1b
Instead of:
- OU1
- OU1a
- OU1b
etc.
How can i get this working?
Roland
|
|
|
|
|
Your searching the entire subtree under the starting container. Don't.
The trick is to populate only the top level of the treeview, putting a dummy child under each leaf so you get the little plus sign next to it. Upon the user clicking each node, you have to requery AD to get the containers under that particular node, and fill in the nodes under the node that was clicked.
Didn't think this was going to be that complicated, did you?
-- modified at 17:59 Sunday 18th March, 2007
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You are right, I didn't think that it is this complicated. I'm trying to get it working, but not with any succes. Do you have some code examples so that i could get this working?
Thanks,
Roland
|
|
|
|
|
I found the code below, but when putting this into a form, i get some errors.
The code i use:
Imports System.DirectoryServices<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
Private sRootDSE As String<br />
#Region " Windows Form Designer generated code "<br />
<br />
Public Sub New()<br />
MyBase.New()<br />
<br />
'This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
'Add any initialization after the InitializeComponent() call<br />
sRootDSE = GetRootDSE()<br />
End Sub<br />
<br />
'Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
<br />
'Required by the Windows Form Designer<br />
Private components As System.ComponentModel.IContainer<br />
<br />
'NOTE: The following procedure is required by the Windows Form Designer<br />
'It can be modified using the Windows Form Designer.<br />
'Do not modify it using the code editor.<br />
Friend WithEvents TreeView1 As System.Windows.Forms.TreeView<br />
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub<br />
InitializeComponent()<br />
Me.components = New System.ComponentModel.Container<br />
Dim resources As System.Resources.ResourceManager = New<br />
System.Resources.ResourceManager(GetType(Form1))<br />
Me.TreeView1 = New System.Windows.Forms.TreeView<br />
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)<br />
Me.SuspendLayout()<br />
'<br />
'TreeView1<br />
'<br />
Me.TreeView1.ImageList = Me.ImageList1<br />
Me.TreeView1.Location = New System.Drawing.Point(32, 24)<br />
Me.TreeView1.Name = "TreeView1"<br />
Me.TreeView1.Size = New System.Drawing.Size(240, 248)<br />
Me.TreeView1.TabIndex = 0<br />
'<br />
'ImageList1<br />
'<br />
Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)<br />
Me.ImageList1.ImageStream =<br />
CType(resources.GetObject("ImageList1.ImageStream"),<br />
System.Windows.Forms.ImageListStreamer)<br />
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent<br />
'<br />
'Form1<br />
'<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
Me.ClientSize = New System.Drawing.Size(552, 302)<br />
Me.Controls.Add(Me.TreeView1)<br />
Me.Name = "Form1"<br />
Me.Text = "Form1"<br />
Me.ResumeLayout(False)<br />
<br />
End Sub<br />
<br />
#End Region<br />
<br />
Sub GetOU()<br />
<br />
Dim root As New DirectoryEntry("LDAP://" & sRootDSE)<br />
<br />
Dim searcher As New DirectorySearcher(root)<br />
<br />
Dim s As SearchResult<br />
Dim nodearr() As TreeNode<br />
searcher.SearchScope = SearchScope.OneLevel<br />
Dim I As Integer<br />
Dim cp As IComparer<br />
cp = New NodeComparer<br />
<br />
ReDim nodearr(searcher.FindAll.Count - 1)<br />
<br />
For Each s In searcher.FindAll<br />
Dim no As New TreeNode(s.GetDirectoryEntry.Properties("Name").Value.ToString, GetObjectClass(s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString), GetObjectClass(s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString))<br />
no.Tag = s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString()<br />
nodearr(I) = no<br />
<br />
I += 1<br />
Next<br />
Array.Sort(nodearr, cp)<br />
<br />
Dim k As TreeNode<br />
<br />
TreeView1.Nodes.AddRange(nodearr)<br />
<br />
End Sub<br />
<br />
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
GetOU()<br />
End Sub<br />
<br />
Private Sub TreeView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.DoubleClick<br />
<br />
If TreeView1.SelectedNode.GetNodeCount(True) < 1 Then <br />
Dim root As New DirectoryEntry("LDAP://" & TreeView1.SelectedNode.Tag.ToString)<br />
Dim searcher As New DirectorySearcher(root)<br />
Dim s As SearchResult<br />
Dim nodearr As TreeNode()<br />
searcher.SearchScope = SearchScope.OneLevel<br />
Dim I As Integer<br />
Dim cp As IComparer<br />
cp = New NodeComparer<br />
<br />
ReDim nodearr(searcher.FindAll.Count - 1)<br />
<br />
For Each s In searcher.FindAll<br />
Dim no As New TreeNode(s.GetDirectoryEntry.Properties("Name").Value.ToString, GetObjectClass(s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString), GetObjectClass(s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString))<br />
no.Tag = s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString()<br />
nodearr(I) = no<br />
I += 1<br />
Next<br />
Array.Sort(nodearr, cp)<br />
TreeView1.SelectedNode.Nodes.AddRange(nodearr)<br />
TreeView1.SelectedNode.Expand()<br />
End If<br />
<br />
End Sub<br />
<br />
Private Function GetRootDSE() As String<br />
<br />
Dim RootEntry As New DirectoryEntry("LDAP://RootDSE")<br />
Return RootEntry.Properties("DefaultNamingContext").Value.ToString<br />
'Add error handling<br />
End Function<br />
<br />
Private Function GetObjectClass(ByVal DN As String) As Integer<br />
Dim m As New DirectoryEntry("LDAP://" & DN)<br />
<br />
Dim r As New DirectoryEntry(m.NativeObject.schema.ToString)<br />
<br />
Select Case r.Name<br />
Case "organizationalUnit"<br />
Return 0<br />
Case "computer"<br />
Return 1<br />
Case "user"<br />
Return 2<br />
Case Else<br />
Return 0<br />
End Select<br />
End Function<br />
<br />
End Class<br />
Class NodeComparer<br />
Implements IComparer 'Implement the IComparer Interface<br />
Overloads Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare<br />
Return CType(x, TreeNode).ImageIndex - CType(y, TreeNode).ImageIndex<br />
End Function<br />
End Class
The errors i get at VB 2005 Express Edition:
Error 1 'Protected Overrides Sub Dispose(disposing As Boolean)' has multiple definitions with identical signatures. Line 7 Column 29
Error 2 'components' is already declared as 'Private Dim components As System.ComponentModel.IContainer' in this class. Line 28 Column 13
Error 3 'TreeView1' is already declared as 'Friend Dim WithEvents TreeView1 As System.Windows.Forms.TreeView' in this class. Line 33 Column 23
Error 4 Identifier expected. Line 35 Column 58
Warning 5 Unused local variable: 'k'. Line 97 Column 13
What is going wrong?
Roland
|
|
|
|