|
What have you tried ? You can't put an image in a textbox, but you can use Bitmap.FromFile to get a bitmap from the path selected, or FromStream if the dialog offers a stream. A picture box is the easy way to show an image.
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 )
|
|
|
|
|
ok thank you. i will try what you said. thanks again
Don't block the drive way of all the newbies in programming.
|
|
|
|
|
i use following code:
--------------------------------------
private sub ShareFolder()
Dim ct As New DirectoryEntry("WinNT://" +
SystemInformation.ComputerName + "/LanmanServer")
ct.AuthenticationType = AuthenticationTypes.Signing Or _
AuthenticationTypes.Sealing Or _
AuthenticationTypes.Secure
ct.Username = Nothing
ct.Password = Nothing
Dim shares As DirectoryEntries = ct.Children
Dim share As DirectoryEntry =
ct.Children.Add("foldersharename", "fileshare")
share.Properties("path").Add("c:\new folder")
share.CommitChanges()
end sub
-------------------------------------
After calling ShareFolder function,"c:\new folder" folder was shared.
But when opening the folder from any other computer than mine through
LAN (Local Area Network), "\\Tulgaa\foldersharename is not accessible. You
might not have permission to user this network resource. Contact the
administrator of this server ot find out if you have access
permissions" msg is thrown. When I share a folder manually from
Explorer, all is fine.
How to solve this problem, tell me please !!!
Tulgaa
-- modified at 2:33 Saturday 21st April, 2007
|
|
|
|
|
If your example code is accurate, then you've shared out the folder "C:\New Folder" with a share name of "foldersharename". You then tried to open the folder from another machine using the wrong name. You have to use the sharename in the UNC path, not the folder name.
\\server\sharename\subfolder\subfolder\file
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
i tried to open the folder from another machine using correct path which was "\\server\foldersharename" .
i'm trying to share a folder by another way. code here: >>
Sub MyShare()<br />
Dim serverName, UserName, AdminName, UserAcct As String<br />
Dim Ace1 As Management.ManagementObject<br />
serverName = SystemInformation.ComputerName<br />
Dim scope As New ManagementScope("\\" + SystemInformation.ComputerName + "\root\cimv2")<br />
Dim wmiShare As New Management.ManagementClass(scope, New Management.ManagementPath("Win32_Share"), Nothing)<br />
UserName = SystemInformation.UserName<br />
<br />
Dim userAccount As ManagementObject<br />
Dim userExists As Boolean = False<br />
Dim userSearcher As New ManagementObjectSearcher(scope, New SelectQuery(String.Format("SELECT * from Win32_UserAccount WHERE domain='{0}'", serverName))) <br />
For Each userAccount In userSearcher.Get()<br />
If (String.Compare(UserName, userAccount("Name"), True) = 0) Then<br />
userExists = True<br />
Exit For<br />
End If<br />
Next<br />
if not userExists then<br />
Msgbox("User not found")<br />
Exit Sub<br />
End if<br />
<br />
Ace1 = SetAce(scope, 2032127, 3, 0, SetTrustee(scope, serverName, UserName, GetBinarySid(scope, userAccount("sid")))) '<br />
<br />
Dim secDescriptor As Management.ManagementObject<br />
secDescriptor = New Management.ManagementClass(scope, New Management.ManagementPath("Win32_SecurityDescriptor"), Nothing).CreateInstance()<br />
secDescriptor("ControlFlags") = 4<br />
secDescriptor("DACL") = New Management.ManagementObject() {Ace1}<br />
<br />
Dim inParams As Management.ManagementBaseObject<br />
inParams = wmiShare.GetMethodParameters("Create")<br />
inParams("Access") = secDescriptor<br />
inParams("Path") = "C:\new folder"<br />
inParams("Name") = "foldersharename"<br />
inParams("Type") = 0<br />
inParams("MaximumAllowed") = 5<br />
inParams("Description") = "FolderDescriptionHere"<br />
Dim outParams As Management.ManagementBaseObject<br />
<br />
outParams = wmiShare.InvokeMethod("Create", inParams, Nothing)<br />
MsgBox("Successful")<br />
End Sub<br />
<br />
Function GetBinarySid(ByVal scope As ManagementScope, ByVal sid As String)As Byte() <br />
Dim wmiSid As New ManagementObject(scope, New ManagementPath(String.Format("Win32_SID.SID='{0}'", sid)), Nothing)<br />
Return wmiSid("BinaryRepresentation")<br />
End Function<br />
<br />
Function SetTrustee(ByVal scope As Management.ManagementScope, ByVal domain As String, ByVal name As String, ByVal UserSid As Byte()) As Management.ManagementObject<br />
Dim wmiTrustee As Management.ManagementObject<br />
wmiTrustee = New Management.ManagementClass(scope, New Management.ManagementPath("Win32_Trustee"), Nothing).CreateInstance()<br />
wmiTrustee("Domain") = domain<br />
wmiTrustee("Name") = name<br />
wmiTrustee("SID") = UserSid<br />
Return wmiTrustee<br />
End Function<br />
<br />
Function SetAce(ByVal scope As Management.ManagementScope, ByVal accessMask As Integer, ByVal aceFlags As Integer, ByVal aceType As Integer, ByVal wmiTrustee As Management.ManagementObject) As Management.ManagementObject<br />
Dim wmiAce As Management.ManagementObject<br />
wmiAce = New Management.ManagementClass(scope, New Management.ManagementPath("Win32_ACE"), Nothing).CreateInstance()<br />
wmiAce("AccessMask") = accessMask<br />
wmiAce("AceFlags") = aceFlags<br />
wmiAce("AceType") = aceType<br />
wmiAce("Trustee") = wmiTrustee<br />
Return wmiAce<br />
End Function
But steel that message appeared. When I tried to open the folder from Windows Explorer from other machines, message appears again. My user is of Administrator group and has no password. When I share a folder manually from Explorer, all is fine. What is wrong with me?
|
|
|
|
|
battulga wrote: My user is of Administrator group and has no password.
Windows file sharing hates blank passwords. Try setting yourself a password and try it again.
|
|
|
|
|
I have 3 images of different sizes and i want to display all of them in a loop.
how can i resize the images to picture box's size.
|
|
|
|
|
A picture box can be set to do this for you automatically.
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 )
|
|
|
|
|
Picture box will resize itself to the size of picture.
But i want to resize the picture according to the size of picture box.
|
|
|
|
|
No, a picture box does not resize itself, it stretches the image to fit itself.
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 )
|
|
|
|
|
Actually it does both. It all depends on the sizemode that's been selected.
|
|
|
|
|
OK, I knew there were different modes, I had no idea one of those actually resizes the picturebox. But then, I'd never use a picture box in my code.
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 )
|
|
|
|
|
Hey everyone, just got an assignment to create an app to take a complex equation (i.e. 20+4/2-6*3) and compute it. I know that you need to take the expression and put it into postfix notation, but how do get to that point and how do I calculate it. I don't usually ask, but we just got the assignment this week and I leave for another class in Chicago over the weekend, so I will be pressed to get it done before Tuesday.
Any ideas to help me on my way?
|
|
|
|
|
Perhaps check for occurences of the functional characters and return substrings between them, then calculate in the correct order via BDMAS (Brackets, Division, Multiplication, Addition, Subtraction). The actual code i don't know for sure but i'll have a go at it for you.
Posted by The ANZAC
|
|
|
|
|
This is a truly complex project. One beyond my skill. As far as i can work out, you need to split the string at the specific locations, take note of the function at that point, split the equation either side of it, then priorise the calculations according to the order of operations. Sounds simple, the code is more difficult. I hope this has helped.
Posted by The ANZAC
|
|
|
|
|
Yeah, I've got it set up now to split the original equation (which is in string format) on the condition on whether of not you have a number or an operator. The operator goes to a stack while the numbers go to an array list. The operators only get popped out of the stack based on the conditions of solving a complex equation, but the problem I am having is when I check the next item in the string to make sure that it isn't another part of the number.
|
|
|
|
|
Okay, I figured out how to get the postfix order. Yesterday I remembered that in a data structures class, we built a c++ program that did the same, but we only used variables and didn't do any equation solving. Luckily, I never sell back my CS school books, and I had seen my old data structures book in our storage just last Sunday, so I pulled it out and got the program half way finished. So all I have left is to do the solving.
|
|
|
|
|
I have a Class (Class1) and a Form (Form1)that have a object (cl as Class1)
Whene I added a first new DataRow to a DataTable in cl a Sub (Row_Changed)was called One time
and Whene I added a Second new DataRow to a DataTable in cl a Sub (Row_Changed)was calling two times
I Want a Sub was called One time
------------------------------------------------------------------------------
Public Class Class1
Public Dt As New DataTable
Dim N As Integer
Sub New()
End Sub
Private Sub Row_Changed(ByVal Sender As Object, ByVal e As DataRowChangeEventArgs)
If e.Action = DataRowAction.Add Then
e.Row(1) = N - 1
MsgBox(e.Action.ToString & Str(N) & "," & e.Row(1))
End If
End Sub
Public Sub Start()
AddHandler Dt.RowChanged, AddressOf Row_Changed
End Sub
End Class
--------------------------------------------------------------------------------
Public Class Form1
Dim N As Integer
Dim Cl As New Class1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TestDataSet.Tables(0) has Two Column
Cl.Dt = TestDataSet.Tables(0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Cl.Start()
Dim Dr As DataRow
N += 1
Dr = Cl.Dt.NewRow
Dr(0) = N
Dr(1) = Str(N)
Cl.Dt.Rows.Add(Dr)
End Sub
End Class
|
|
|
|
|
I only looked breifly, but you could remove the handler after the sub has been called once...Just put
RemoveHandler Dt.RowChanged, AddressOf Row_Changed
right after MsgBox(e.Action.ToString & Str(N) & "," & e.Row(1))
in Private Sub Row_Changed
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
Is there a way to initialize a DLL in VB.Net? When you build a class library.
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
That depends on what you mean by "initialize a DLL"??
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Sorry, I should have said that better. What I mean is, is there a way to run some method within the dll immediately after the dll is loaded into memory?
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
How are you loading the dll? Are you using Reflection(Late binding) or creating a reference (early binding). If you are late binding use a default constructor otherwise with early bound objects put your method call in any of the constructors which are important.
Personally I like to use an interface with the desired method and call the method when I use reflection to late bind. I am not sure if this is what you are looking for but I hope it helps.
|
|
|
|
|
Thanks, I figured that is what I would have to do, I was just wondering if there was some built in event or something along those lines that would be fired when a dll was loaded into memory...My error handling class needs to initialize as soon as it is loaded into memory, but I dont think that is really going to be possible so what I did was to seperate it into its own dll, make it completely shared, build a sub Main for the startup project of my application, and initialize it there...then all of the other dll's in my project include a reference to the dll and it catches exceptions from them as well...here is a copy of my class if you are interested...It's basicly just an exception logger:
'NOTE: If running on a development machine, this will not work properly unless HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting is set to 1
Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports ZipsCommon
Public Class ErrorHandler
#Region " Variables "
Private Shared mHasBeenInited As Boolean = False
#End Region
#Region " Constructor Lockout "
Private Sub New()
End Sub
#End Region
#Region " Event Handler "
Private Shared Sub ThreadHandler(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
LogException(e.Exception, True)
End Sub
Private Shared Sub UnhandledHandler(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
LogException(e.ExceptionObject, True)
End Sub
#End Region
#Region " Subs "
Public Shared Sub Init()
If mHasBeenInited Then Exit Sub
AddHandler Application.ThreadException, AddressOf ThreadHandler
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledHandler
mHasBeenInited = True
End Sub
Public Shared Sub LogException(ByVal ex As Exception)
LogException(ex, False)
End Sub
Private Shared Sub LogException(ByVal ex As Exception, ByVal wasUnhandled As Boolean)
Try
'NOTE: To avoid circular dependencys, all errors will be loged to the database at->SetupInfo.DBConnStr
Dim cmd As SqlCommand = New SqlCommand("NewError", New SqlConnection(SetupInfo.DBConnStr))
With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@StoreID", SetupInfo.StoreID)
.Parameters.AddWithValue("@ExMsg", ex.Message)
.Parameters.AddWithValue("@StckTrc", ex.StackTrace)
.Parameters.AddWithValue("@WasUnhandled", wasUnhandled)
.Connection.Open()
.ExecuteNonQuery()
.Connection.Close()
.Connection.Dispose()
.Dispose()
End With
Catch ex2 As Exception
End Try
End Sub
Public Shared Sub Dispose()
If Not mHasBeenInited Then Exit Sub
RemoveHandler Application.ThreadException, AddressOf ThreadHandler
RemoveHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledHandler
mHasBeenInited = False
End Sub
#End Region
End Class
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
Nevermind guys, I found the answer I needed here:
Clickety[^]
I wrote a class that should handle unhanded exceptions, but it is not working...below is the code. It is in a dll that I import into my project. I think the issue could be that the error handler is in the dll and not something In my current application, so maybe it is a thread issue? If you have any suggestions or if you know what the problem is, please let me know. Thanks.
Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports ZipsCommon
Public Class ErrorHandler
#Region " Variables "
Private Shared mHasBeenInited As Boolean = False
#End Region
#Region " Constructor Lockout "
Private Sub New()
End Sub
#End Region
#Region " Event Handler "
Private Shared Sub TheHandler(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
LogException(e.Exception, True)
End Sub
#End Region
#Region " Subs "
Public Shared Sub Init()
If mHasBeenInited Then Exit Sub
AddHandler Application.ThreadException, AddressOf TheHandler
mHasBeenInited = True
End Sub
Public Shared Sub LogException(ByVal ex As Exception)
If Not mHasBeenInited Then Init()
LogException(ex, False)
End Sub
Private Shared Sub LogException(ByVal ex As Exception, ByVal wasUnhandled As Boolean)
Try
If Not mHasBeenInited Then Init()
'NOTE: To avoid circular dependencys, all errors will be loged to the database at ->SetupInfo.DBConnStr
Dim cmd As SqlCommand = New SqlCommand("NewError", New SqlConnection(SetupInfo.DBConnStr))
With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@StoreID", SetupInfo.StoreID)
.Parameters.AddWithValue("@ExMsg", ex.Message)
.Parameters.AddWithValue("@StckTrc", ex.StackTrace)
.Parameters.AddWithValue("@WasUnhandled", wasUnhandled)
.Connection.Open()
.ExecuteNonQuery()
.Connection.Close()
.Connection.Dispose()
.Dispose()
End With
Catch ex2 As Exception
End Try
End Sub
Public Shared Sub Dispose()
If Not mHasBeenInited Then Exit Sub
RemoveHandler Application.ThreadException, AddressOf TheHandler
mHasBeenInited = False
End Sub
#End Region
End Class
-- modified at 18:58 Thursday 19th April, 2007
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|