 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Hi,
THIS IS NOT FOR .NET.
I need this in vbs, js and vba
I want to findout the path to the active user his pictures.
I know how the find the documents, desktop of favorites throu specialfolders but pictures is'nt in it
In google I didn't find anything usefull.
Jan
|
|
|
|
 |
There is no enumeration to get to Pictures from VBA and VBScript. Pictures was never added to those old things.
Javascript in a browser has no access to the users filesystem so that's pretty much useless, unless you want to describe what you're doing with it.
The work around is to just use the path of "%USERPROFILE%\Pictures".
|
|
|
|
 |
..that would be assuming a desktop with the English culture.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
indeed. This is not working for us this is a working pc and all data folders are on a nas server.
thanks for the responses anyway.
maybee I can find it in the registry? but where?
Jan
|
|
|
|
 |
Alternatively, you could ask the user for the location.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
For VBA, you'll need to use either SHGetFolderPath[^] or the newer SHGetKnownFolderPath[^].
How To Use the SHGetFolderPath Function from Visual Basic[^]
Option Explicit
Private Const S_OK = &H0
Private Const S_FALSE = &H1
Private Const E_INVALIDARG = &H80070057
Private Const MAX_PATH = 260
Private Const SHGFP_TYPE_CURRENT = 0
Private Const CSIDL_MYPICTURES = &H27
Private Declare Function SHGetFolderPath Lib "shfolder" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
Private Function GetFolderPath(ByVal csidl As Long) As String
Dim path As String
Dim returnValue As Long
path = String(MAX_PATH, 0)
returnValue = SHGetFolderPath(0, csidl, 0, SHGFP_TYPE_CURRENT, path)
Select Case returnValue
Case S_OK
GetFolderPath = Left(path, InStr(1, path, Chr(0)) - 1)
Case S_FALSE
GetFolderPath = vbNullString
Case E_INVALIDARG
Err.Raise 5, "csidl", "Invalid folder"
End Select
End Function
Public Function GetPicturesFolderPath() As String
GetPicturesFolderPath = GetFolderPath(CSIDL_MYPICTURES)
End Function
For script running locally, you could read the folder path from the registry (HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders). However, there is a warning in that key telling you not to do that!
Since you can't call Windows functions directly from script, you'd need to create a COM object to call the Windows API, and invoke that object from your script.
For script running in the browser, there is no way to access this information.
EDIT: There's also HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, which doesn't have that warning. But the recommendation is still to use the Windows API.
In other words, the "Shell Folders" key exists solely to permit four programs written in 1994 to continue running on the RTM version of Windows 95.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 2 days ago.
|
|
|
|
 |
Richard Deeming wrote: However, there is a warning in that key telling you not to do that!
I thought you mistyped this until I went and looked at the key. No, you didn't. It's in there!
The path to Pictures is listed as "My Pictures", but like you said before, is this name localized? I have no idea.
|
|
|
|
 |
I don't think the names would be localized, but I don't have a non-English version of Windows to check.
I've just added a link to a blog post from Raymond Chen, who explains that the "Shell Folders" key exists solely to permit four programs written in 1994 to continue running on the RTM version of Windows 95.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
The names are localized. I got a folder "My Pictures", one called "Pictures" and one "Mijn Afbeeldingen". To make things worse, this does not say anything about the actual location, as my "Mijn Afbeeldingen" points to a completely different harddrive.
More on Wikipedia[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
I'd expect the names of the folders to be localized. But what about the names of the values in the "User Shell Folders" registry key?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Richard Deeming wrote: I'd expect the names of the folders to be localized Yup.
Richard Deeming wrote: But what about the names of the values in the "User Shell Folders" registry key? Yes, my apologies for not thinking.
English, both on a Dutch and a German machine. Called "CommonPictures" on this machine, pointing to the correct physical path. Keys are usually not translated, because that would defeat the purpose of having one.
..so, remotely reading the registry as an admin, just to find a path? Still sounds like a bad idea
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
Eddy Vluggen wrote: nglish, both on a Dutch and a German machine. Called "CommonPictures" on this machine, pointing to the correct physical path. Keys are usually not translated, because that would defeat the purpose of having one.
Considering the "fix" that this key was created for, would it really surprise anyone if someone at MS did something that stupid?
|
|
|
|
|
 |
His blog is filled with those kind of examples. Well worth the read if you have some time to kill
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
"Time"? What is this "time" you speak of?
I'm in the middle of a 6 week stint of being a single parent while the wife travels for work. 24 hours in a day isn't enough. I have to give credit to those who do this full-time. It ain't easy.
|
|
|
|
 |
i'll give this a try
thanks to all
btw I already found that reg key
Jan
|
|
|
|
 |
Dear Friends
how to append char in VB6.0
thanks
|
|
|
|
 |
Same answer as below; please read the documentation.
|
|
|
|
 |
If you're asking question this basic, you SERIOUSLY need to pick up a book on VB.NET and work through it.
Forget VB6.
|
|
|
|
 |
Dear friends
i write a vb program. in this program a string "john????". and in string count char "?".
thanks
|
|
|
|
 |
See the documentation for the String class, there is most likely a method that gives the result.
|
|
|
|
 |
Hi guys,
Is any having Pads layout vb-scripting Documents
kindly help me anyone guys.
I believe that will get quick response.
[edit user="me"]
Removed bolding - we can all read.
[/edit]
modified 21-Sep-16 4:12am.
|
|
|
|
 |
The quick response is "What does that mean?". It makes absolutely no sense in English. I realise that English may not be your first language, but please explain what you want clearly or nobody will be able to help you.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
 |
A 5for optoholic
Does it changes your perspective?
|
|
|
|
 |
It depends how thick the bottom of the glass is!
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
 |
Karthi veerappan wrote: Is any having Pads layout vb-scripting Documents This does not make any sense. Please explain clearly.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
This creates an email for each user and lists all their roles. I have been racking my brain trying to add another loop (possibly For Each?) that creates an email for all users of a given supervisor (column 7). For example, if a super has 3 employees, it creates 3 emails, I want it to create 1. It should loop through all supervisors sending them an email that includes all their workers.
I left the email piece off, below code works in Excel but generates an email for every user (column 3).
Anyone have any ideas? Please and thank you.
Sub LoopUsers()
Dim l As Long
With Sheet1
For l = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If sUser = "" Then
sGreeting = .Cells(l, 1).Value
sEmail = .Cells(l, 2).Value
sCC = .Cells(l, 9).Value
sUser = .Cells(l, 3).Value
sName = .Cells(l, 4).Value
sDescription = .Cells(l, 5).Value
sRole = .Cells(l, 6).Value
Else
sRole = sRole & ", " & .Cells(l, 6).Value
End If
If .Cells(l + 1, 3) <> sUser Then
Call SendEmail
sUser = ""
End If
Next l
End With
End Sub
|
|
|
|
 |
Sort by supervisor and then loop through your cells. Concatenate the list of employees and when the supervisor changes you send the email and reset the variable storing the employees.
Pretty simple. Just think it through, perhaps write it down on paper and then translate to code.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
Not sure I exactly follow - wouldn't a For Each or While loop work here? Not well versed in nested loops. Seems simple bu tI have yet to get anything to work.
|
|
|
|
 |
Any type of loop will work. Again, just write it out on paper and then translate to code if you are stuck.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
Trying this but keep getting a compile error "Next without For". Statements are lined up, not sure - breaking on Next l
Sub LoopUsers()
Dim l As Long
Dim j As Long
With Sheet1
For l = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If sSuper = "" Then
sSuper = .Cells(l, 7).Value
For j = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If sUser = "" Then
sGreeting = .Cells(j, 1).Value
sEmail = .Cells(j, 2).Value
sCC = .Cells(j, 9).Value
sUser = .Cells(j, 3).Value
sName = .Cells(j, 4).Value
sDescription = .Cells(j, 5).Value
sRole = .Cells(j, 6).Value
Else
sRole = sRole & ", " & .Cells(j, 6).Value
End If
If .Cells(j + 1, 3) <> sUser Then
End If
Next j
End If
If .Cells(l + 1, 7) <> sSuper Then
Call SendEmail
sSuper = ""
Next l
End With
End Sub
|
|
|
|
 |
If .Cells(l + 1, 7) <> sSuper Then
Call SendEmail
sSuper = ""
Next l
There is no matching end If clause.
|
|
|
|
 |
thank you, I added that in and it works, however not exactly the way I want. Loops through supervisor but not getting all users.
Sub LoopUsers()
Dim l As Long
Dim j As Long
Dim k As Long
With Sheet1
For l = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If sSuper = "" Then
sGreeting = .Cells(l, 1).Value
sEmail = .Cells(l, 2).Value
sCC = .Cells(l, 9).Value
sSuper = .Cells(l, 7).Value
For j = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If sUser = "" Then
sUser = .Cells(j, 3).Value
sName = .Cells(j, 4).Value
sDescription = .Cells(j, 5).Value
For k = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If sRole = "" Then
sRole = .Cells(k, 6).Value
Else
sRole = sRole & ", " & .Cells(k, 6).Value
End If
Next k
End If
If .Cells(j + 1, 3) <> sUser Then
End If
Next j
End If
If .Cells(l + 1, 7) <> sSuper Then
Call SendEmail
sSuper = ""
sUser = ""
sRole = ""
End If
Next l
End With
End Sub
|
|
|
|
 |
Jughead3 wrote: Loops through supervisor but not getting all users. It's not clear what your code is supposed to be doing, so I cannot make any suggestion. When you say "Loops through supervisor", what exactly does that mean, and where are the users?
|
|
|
|
 |
I can't post worksheet so I explain in simplest terms
column A + B for email piece
column C = username (USER)
column D = name of user
column E = description (for email)
column F = role (user's role or roles)
column G = supervisor (of user)
I have code that loops through users and generates emails perfectly BUT let's say the supervisor has 20 employees; they would receive 20 emails in this scenario. I would like for them to receive 1 single email listing ALL of their users. This is what I mean by looping through the supervisor - getting their user data including roles.
Hope this makes better sense. Thank you.
|
|
|
|
 |
Then you just need to loop through all the records making a list (or lists) where the supervisor is the same. Then use each list to send the emails.
|
|
|
|
 |
Not that simple. Data is an extract - usernames can repeat along with supervisor. The unique piece (data point) is their role which is why this is in the code
sRole = .Cells(l, 6).Value
Else
sRole = sRole & ", " & .Cells(l, 6).Value
|
|
|
|
 |
I am sorry bu that means nothing to me, as I have no idea what the structure of your data is. However, the issue is the same as most problems of this type. You must run through the data as many times as necessary to build the groups which have the common item (e.g supervisor, role etc) that you are interested in. The first thing to do is write down all the common criteria, and then decide on how to build the groups using those rules.
|
|
|
|
 |
Hello !
I have a vb.net program.
In my program I want to use dates in the format "dd/MM/yyyy".
But when the windows date format is different I get errors.
For example if my program is executed in a Pc where the date is in the format : mm/dd/yyyy I get errors for example when day is more than 12 :
Dim dt As DateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")
I get error :
Conversion from string "20/09/2016 21:21:47" to type 'Date' is not valid.
What can I do to make my program work whatever the windows date format is configured.
|
|
|
|
 |
That error does not happen where the date is formatted as a string. It happens when exactly the opposite happens: when the string is parsed to return a DateTime. At those positions, you must use DateTime.Parse("dd/MM/yyyy HH:mm:ss")
|
|
|
|
 |
This is why all VB.NET programs should be compiled with Option Strict On.
You're taking a DateTime, converting to a String, and then assigning that String to a DateTime value.
Without Option Strict, VB is attempting to convert that String back to a DateTime. But it has to make some assumptions, one of which is that the String represents a date formatted using the current culture settings - in this case, US-format dates.
If you turn on Option Strict, you will get a compiler error telling you that you cannot store a String in a DateTime variable.
You could use DateTime.Parse or DateTime.TryParse to try to convert the String back into a DateTime.
But it would be much simpler to just not convert the DateTime to a String in the first place!
Dim dt As DateTime = DateTime.Now
Remember, a DateTime value does not have a "format" stored with it. It is simply the number of ticks since midnight on 1st January 0001. You only use a format when you are displaying the value to the user, or parsing a user-supplied string back into a DateTime.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Hello !
I'm using visual studio 2013.
In my app.config , there are 3 connections strings :
<connectionStrings><add name="db1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=PERSONALPC\MSSQL2008R2;initial catalog=db1;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="db2Entities" connectionString="metadata=res://*/Model2.csdl|res://*/Model2.ssdl|res://*/Model2.msl;provider=System.Data.SqlClient;provider connection string="data source=PERSONALPC\MSSQL2008R2;initial catalog=db2;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="db3Entities" connectionString="metadata=res://*/Model3.csdl|res://*/Model3.ssdl|res://*/Model3.msl;provider=System.Data.SqlClient;provider connection string="data source=PERSONALPC\MSSQL2008R2;initial catalog=db3;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Now , I want to access these connections strings , using the following code :
Dim connstringtemplate1 As String = System.Configuration.ConfigurationManager.ConnectionStrings(1).ConnectionString.ToString
This string has "NULL" value
Dim connstringtemplate2 As String = System.Configuration.ConfigurationManager.ConnectionStrings(2).ConnectionString.ToString
This string has the first connection string
Dim connstringtemplate3 As String = System.Configuration.ConfigurationManager.ConnectionStrings(3).ConnectionString.ToString
This string has the second connection string
Dim connstringtemplate4 As String = System.Configuration.ConfigurationManager.ConnectionStrings(4).ConnectionString.ToString
This string has the third connection string
Also if I use this :
Dim nr As Integer = System.Configuration.ConfigurationManager.ConnectionStrings.Count
The value of nr is 5.
I have only 3 connection strings , so why there are 5 and the first is empty ?
This problem appear after I have installed the Update 5 on visual studio 2013.
Before everything was ok.
Thank you !
|
|
|
|
 |
Why are you getting connectionstring by index instead of getting them by using their name?
|
|
|
|
 |
desanti wrote: I have only 3 connection strings , so why there are 5 and the first is empty ? They are probably getting merged in from the machine.config file. You can use <clear /> in .config to get rid of them. c# - ConfigurationManager.ConnectionStrings returns extra connection string from machine.config - Stack Overflow[^]
But, as pointed out in the other response, the better option is to refer to them using a name rather than depending on their order. ConfigurationManager.ConnectionStrings[connectionName].ConnectionString
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
First off, I'm sorry if this is in the wrong section .I have this project that needed to receive data from PLC. The PLC comes from Keyence. Right now, I'm having hard time on how can I create it. Anyhelp will do. Thank you!
|
|
|
|
 |
What sort of help are you looking for? Have you studied the documentation of the PLC device (whatever that is) to see whether you are accessing it correctly? Have you written any VB.NET code yet, and if so where is the problem?
|
|
|
|
 |
Hmmm... where to start?
A PLC is a Programmable Logic Controller - basically an industrial computer.
So, how does the PLC make the data available - a direct connection or a networked connection?
Does the manufacturer have any code samples of how to connect to their device and get data from it?
We are generally willing to help, but your question is very wide open...
|
|
|
|
 |
It's been a long time since VB6 has mystified me in its behaviour!
I have a function that solves Kakuro puzzles. It uses a 2D and a 3D array (both Integer) as its main data structures and employs a conventional DFS approach.
Naturally I compile to EXE with all run-time checks disabled for maximum grunt.
Recently I accidentally turned off these optimizations (I was in the wrong project window). But when I restored them and rebuilt the EXE I found to my horror that my solver has lost its mojo.
Every benchmark test I have reports exactly the same results (including, importantly, the number of DFS recursions) BUT all of them run 3 times slower than before. Nothing else has changed that I can think of.
I'm at a loss to explain this. Any ideas?
Mathimagics
|
|
|
|