|
Pavlex4 wrote: I shuffled word like this: string shuffled_word = new string(word.OrderBy(r => random.Next()).ToArray()); That is LINQ, you wouldn't need to execute a command-object for that.
Pavlex4 wrote: But I don't know how to every time I click button show letter of word on other label? Execute the same method again; random would mean that it picks a random word, meaning there would be a different one on each execution.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I made every time I click button to show word letter on each label.But this only works with word that has lenght 12,for words that have lenght 10 and 11 program crashes.What should I do?
If word lenght is 10 it should generate 2 random letters and place it somewhere in word,if word lenght is 11 it should generate 1 random letter and place it somewhere in word!!!
Here is my code: [C#] slagalica-kviz-2 - Pastebin.com[^]
|
|
|
|
|
I have fixed problem.How to make that when user enter word using given random letters from labels in textbox,user cannot enter letter that does not exist in given letters!!!
|
|
|
|
|
I don't get a notification if you reply to yourself; meaning I won't know if there's anything new in this thread.
Pavlex4 wrote: How to make that when user enter word using given random letters from labels in textbox,user cannot enter letter that does not exist in given letters!!! Hook on the three keyboard-events from your textbox (KeyDown, Up), see if the character pressed is in the textboxs' text property, and deny if it is.
This would be a new question btw, worth a new thread - as others might have given you this specific answer sooner
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
How to see what character is pressed?
|
|
|
|
|
That is an argument of the event-handler. Select your text-box, go to the properties, select events at the top, double-click on the KeyUp handler, and take a look at the argument "e".
TextBox.OnKeyUp Method (System.Windows.Controls)[^]
That MSDN library should be your home-page btw
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
example:
Public Class Clubcard
Implements IComparable
'''
''' Šifra
'''
Public Property Key As String
'''
''' Ime
'''
Public Property FirstName As String
'''
''' Priimek
'''
Public Property LastName As String
'''
''' Ulica
'''
Public Property Street As String
'''
''' Rojstnodnevni datum
'''
Public Property BirthDate As Date
'''
''' Poštna številka
'''
Public Property PostCode As String
'''
''' Kraj / pošta
'''
Public Property City As String
'''
''' Bonitete
'''
Public Property Bonuses As List(Of Bonus)
End Class
Private Shared Function Compare(Of T)(Object1 As T, object2 As T) As Boolean
'Get the type of the object
Dim type As Type = GetType(T)
'return false if any of the object is false
If Object.Equals(Object1, Nothing) OrElse Object.Equals(object2, Nothing) Then
Return False
End If
'Loop through each properties inside class and get values for the property from both the objects and compare
For Each [property] As System.Reflection.PropertyInfo In type.GetProperties()
If [property].Name <> "ExtensionData" Then
If [property].PropertyType.Name = GetType(List(Of )).Name Then
'I do not know what to do!!!!!!!!!!!!!!!!!?????????????
Else
Dim Object1Value As String = String.Empty
Dim Object2Value As String = String.Empty
If type.GetProperty([property].Name).GetValue(Object1, Nothing) IsNot Nothing Then
Object1Value = type.GetProperty([property].Name).GetValue(Object1, Nothing).ToString()
End If
If type.GetProperty([property].Name).GetValue(object2, Nothing) IsNot Nothing Then
Object2Value = type.GetProperty([property].Name).GetValue(object2, Nothing).ToString()
End If
If Object1Value.Trim() <> Object2Value.Trim() Then
Return False
End If
End If
End If
Next
Return True
End Function
|
|
|
|
|
What is your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
How to compare item property on list(Property Bonuses As List(Of Bonus))
If [property].PropertyType.Name = GetType(List(Of )).Name Then
'I do not know what to do!!!!!!!!!!!!!!!!!?????????????
Else
Dim Object1Value As String = String.Empty
Dim Object2Value As String = String.Empty
If type.GetProperty([property].Name).GetValue(Object1, Nothing) IsNot Nothing Then
Object1Value = type.GetProperty([property].Name).GetValue(Object1, Nothing).ToString()
End If
If type.GetProperty([property].Name).GetValue(object2, Nothing) IsNot Nothing Then
Object2Value = type.GetProperty([property].Name).GetValue(object2, Nothing).ToString()
End If
If Object1Value.Trim() <> Object2Value.Trim() Then
Return False
End If
End If
|
|
|
|
|
Does nobody has any idea!?
|
|
|
|
|
Hi admin,
I tried changed this code. I change the system save picture on form load not on button click. but the result, picture not save correctly. only blank picture. can we save the picture on form load? I use vb6
Private Sub Form_Load()
Call Command1_Click
End Sub
Private Sub Command1_Click()
SaveFormImageToFile frmSaveFormImageToFile, Picture1, "C:\Temp.bmp"
End Sub
Public Sub SaveFormImageToFile(ByRef ContainerForm As Form, ByRef PictureBoxControl As PictureBox, ByVal ImageFileName As String)
Dim FormInsideWidth As Long
Dim FormInsideHeight As Long
Dim PictureBoxLeft As Long
Dim PictureBoxTop As Long
Dim PictureBoxWidth As Long
Dim PictureBoxHeight As Long
Dim FormAutoRedrawValue As Boolean
With PictureBoxControl
'Set PictureBox properties
.Visible = False
.AutoRedraw = True
.Appearance = 0 ' Flat
.AutoSize = False
.BorderStyle = 0 'No border
'Store PictureBox Original Size and location Values
PictureBoxHeight = .Height: PictureBoxWidth = .Width: PictureBoxLeft = .Left: PictureBoxTop = .Top
'Make PictureBox to size to inside of form.
.Align = vbAlignTop: .Align = vbAlignLeft
DoEvents
FormInsideHeight = .Height: FormInsideWidth = .Width
'Restore PictureBox Original Size and location Values
.Align = vbAlignNone
.Height = FormInsideHeight: .Width = FormInsideWidth: .Left = PictureBoxLeft: .Top = PictureBoxTop
FormAutoRedrawValue = ContainerForm.AutoRedraw
ContainerForm.AutoRedraw = False
DoEvents
'Copy Form Image to Picture Box
BitBlt .hDC, 0, 0, FormInsideWidth / Screen.TwipsPerPixelX, FormInsideHeight / Screen.TwipsPerPixelY, ContainerForm.hDC, 0, 0, vbSrcCopy
DoEvents
SavePicture .Image, ImageFileName
DoEvents
ContainerForm.AutoRedraw = FormAutoRedrawValue
DoEvents
End With
End Sub
|
|
|
|
|
vb6. What nostalgia. Try
Private Sub Command1_Click(index As Integer)
Call Command1_Click(0)
Peter Leow
http://www.peterleowblog.com/
https://www.amazon.com/author/peterleow
|
|
|
|
|
I have a scenario where I have to create script .vbs file in the path say for ex: "D:\OfficeCode" and in these path I have list of office code folders like 1101,1102,1103,...etc.,. Now I have to fetch this each of the folder where each folder contains many files . Now I have to move all this files by creating 2 inner folder like Test/Sample and move all the files from the outer folder say for ex : D:\OfficeCode\1101 to the inner folder
D:\OfficeCode\1101\Test/Sample. After copying I have to traverse back to D:\OfficeCode and check inside next folder "1102" and likewise all the folders. If folder is there Test/Sample I have to continue with the next office code. I created script but it is not at all working. Kindly advice me.
R.Sasikumar
|
|
|
|
|
Member 1267546 wrote: Kindly advice me. About what? If you want help with your code then please provide proper details. If you want someone to write the code for you then you are at the wrong place.
|
|
|
|
|
Hi, actually i have created the script but its not properly working. Here is the code snippets
'Getting the inputs from the user - (script lies in the path of "D:\OfficeCode\Myscript.vbs" say example and need to get all the folders under "D:\OfficeCode"
Dim DestFolder,objFSO,bFileAffected,lFlag
bFileAffected = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFolder = objFSO.GetParentFolderName(wscript.ScriptFullName)
Set objStartFolder = objFSO.GetFolder(objFolder)
'msgbox objStartFolder.Path
lob= InputBox("Enter the LOB Name", "Program","MyLOB")
If Trim(lob)="" or IsNumeric(lob) Then
Msgbox "Invalid LOB.Please Enter the LOB",,"Program"
WScript.Quit
End If
moyr= InputBox("Enter the Month & Year", "Program", MonthName(Month(Now()),1) & " " & Year(date))
If Trim(lob)="" or IsNumeric(moyr) Then
Msgbox "Invalid Date/Year.Please Enter the Date/Year",,"Program"
WScript.Quit
End If
ShowSubFolders(objStartFolder)
'Here I am recursively calling the function to get all the folders under D:\OfficeCode
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
GetDestFolder(Subfolder)
ShowSubFolders Subfolder
Next
End Sub
'Creating folder under "D:\OfficeCode\1101" as "\LOB\Year"
'After executing the ChkFiles function here it is again creating LOB\Year folder under "D:\OfficeCode\1101\LOB\Year" as "D:\OfficeCode\1101\\LOB\Year\LOB\Year"
'Now here it want to go back to "D:\OfficeCode\" and get another folder after 1101 ie. 1102 and 'fetch the folder D:\OfficeCode\1102 and again create the below 2 folders "\LOB\Year" under this.
'This process to be repeated for all the folders in "D:\OfficeCode"
Sub GetDestFolder(pFolder)
FlName = pFolder.Path & "\" & lob
If Not objFSO.FolderExists(FlName) Then
Set objFolder = objFSO.CreateFolder(FlName)
End If
FlName = pFolder.Path & "\" & lob & "\" & moyr
If Not objFSO.FolderExists(FlName) Then
Set objFolder = objFSO.CreateFolder(FlName)
End If
End Sub
'Here copy the files in the outer folder "D:\OfficeCode\1101" to inner created folder "D:\OfficeCode\1101\LOB\Year"
Function ChkFiles(pFolder,pDestFolder)
Set objFolder = objFSO.GetFolder(pFolder)
Set colFiles = objFolder.Files
pDestTempFolder= pDestFolder & "\"
For Each objFile in colFiles
strFileName = objFile.Name
If objFSO.GetExtensionName(strFileName) = "pdf" Then
DestFile=objFile.Name
sFile= pFolder & "\" & DestFile
Wscript.Echo "Source File " & sFile
Wscript.Echo "Dest Folder " & pDestTempFolder 'pDestFolder
If objFSO.FileExists(sFile) and pDestFolder<>"" Then
objFSO.CopyFile sFile, pDestTempFolder, True
objFSO.DeleteFile sFile
bFileAffected = True
End if
End If
Next
End Function
Kindly assist me.
R.Sasikumar
|
|
|
|
|
Member 1267546 wrote: but its not properly working. Please edit your question, add <pre> tags around your code so it is properly readable, and explain what you mean by that.
|
|
|
|
|
Hi, actually i have created the script but its not properly working. Here is the code snippets
'Getting the inputs from the user - (script lies in the path of "D:\OfficeCode\Myscript.vbs" say example and need to get all the folders under "D:\OfficeCode"
Dim DestFolder,objFSO,bFileAffected,lFlag
bFileAffected = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFolder = objFSO.GetParentFolderName(wscript.ScriptFullName)
Set objStartFolder = objFSO.GetFolder(objFolder)
'msgbox objStartFolder.Path
lob= InputBox("Enter the LOB Name", "Program","MyLOB")
If Trim(lob)="" or IsNumeric(lob) Then
Msgbox "Invalid LOB.Please Enter the LOB",,"Program"
WScript.Quit
End If
moyr= InputBox("Enter the Month & Year", "Program", MonthName(Month(Now()),1) & " " & Year(date))
If Trim(lob)="" or IsNumeric(moyr) Then
Msgbox "Invalid Date/Year.Please Enter the Date/Year",,"Program"
WScript.Quit
End If
ShowSubFolders(objStartFolder)
'Here I am recursively calling the function to get all the folders under D:\OfficeCode
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
GetDestFolder(Subfolder)
ShowSubFolders Subfolder
Next
End Sub
'Creating folder under "D:\OfficeCode\1101" as "\LOB\Year"
'After executing the ChkFiles function here it is again creating LOB\Year folder under "D:\OfficeCode\1101\LOB\Year" as "D:\OfficeCode\1101\\LOB\Year\LOB\Year"
'Now here it want to go back to "D:\OfficeCode\" and get another folder after 1101 ie. 1102 and 'fetch the folder D:\OfficeCode\1102 and again create the below 2 folders "\LOB\Year" under this.
'This process to be repeated for all the folders in "D:\OfficeCode"
Sub GetDestFolder(pFolder)
FlName = pFolder.Path & "\" & lob
If Not objFSO.FolderExists(FlName) Then
Set objFolder = objFSO.CreateFolder(FlName)
End If
FlName = pFolder.Path & "\" & lob & "\" & moyr
If Not objFSO.FolderExists(FlName) Then
Set objFolder = objFSO.CreateFolder(FlName)
End If
End Sub
'Here copy the files in the outer folder "D:\OfficeCode\1101" to inner created folder "D:\OfficeCode\1101\LOB\Year"
Function ChkFiles(pFolder,pDestFolder)
Set objFolder = objFSO.GetFolder(pFolder)
Set colFiles = objFolder.Files
pDestTempFolder= pDestFolder & "\"
For Each objFile in colFiles
strFileName = objFile.Name
If objFSO.GetExtensionName(strFileName) = "pdf" Then
DestFile=objFile.Name
sFile= pFolder & "\" & DestFile
Wscript.Echo "Source File " & sFile
Wscript.Echo "Dest Folder " & pDestTempFolder 'pDestFolder
If objFSO.FileExists(sFile) and pDestFolder<>"" Then
objFSO.CopyFile sFile, pDestTempFolder, True
objFSO.DeleteFile sFile
bFileAffected = True
End if
End If
Next
End Function
Kindly assist me.
R.Sasikumar
|
|
|
|
|
Have you tried debugging it?
If necessary, modify it to VBA and test it with Excel or something to that effect.
Find out where the error is and word accordingly.
|
|
|
|
|
Dear All
Please provide the solution as how to skip from the inner folder during "for each" loop and jump to the main folder.
R.Sasikumar
|
|
|
|
|
Well that is the third message you have posted and we still have no more idea of what your problem is. It is no good just dumping a load of code and saying "please help me". You need to be specific about what problem occurs in your code and exactly where it occurs. If you don't have that information then use your debugger or some logging techniques to isolate it.
|
|
|
|
|
"It's not working" is not a problem description. You haven't described, in detail, anything about what the code is doing compared to what you expect it to be doing. Without that, there's nothing anyone can do to help you.
|
|
|
|
|
OK i will keep it simple.
I have entered main folder say (D:\officecode) inside which so many subfolder 1101,1102.
'Main folder(say D:\officecode)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
GetDestFolder(Subfolder)
ShowSubFolders Subfolder
Next
End Sub
'After entering the above function it will traverse inside the folders say D:\officecode\1101 and i creating folders inside this folder using the below function
'function to Create 2 new inner folders say 'lob/year
Sub GetDestFolder(pFolder)
If Not objFSO.FolderExists(FlName) Then
Set objFolder = objFSO.CreateFolder(FlName)
End If
FlName = pFolder.Path & "\" & lob & "\" & moyr
If Not objFSO.FolderExists(FlName) Then
Set objFolder = objFSO.CreateFolder(FlName)
End If
End Sub
'After executing this function again it will go to ShowSubFolders function and i recursively call it. But the code getting into the newly create folders "D:\officecode\1101\lob\year" and again creating new folder inside it ""D:\officecode\1101\lob\year\lob\year" but i want to jump to outer folder "D:\officecode" and start with next folder "D:\officecode\1102". Kindly help me to get out of the inner loop in between this recursively function and going back to main folder.
R.Sasikumar
|
|
|
|
|
I can't see all of the code, but it would appear that you're using "global" variables to hold the path strings. Don't. There is no need to use global variables for this stuff. use local variables and it should fix the problem.
|
|
|
|
|
Hello again,
unfortunately my problem (just below) looked like resolved, but something got completely twisted. Something seems to be really wrong in my Settings configuration, since I have the following effects:
- In my main form, I have a custom control, which (of course) is initialized in the form designer.
- A text field in it is supposed to open with a path retrieved from My.Settings, the UserSourcePath.
- When debugging I stop the code during initialization in the line "Private _userSourcPath As String = My.Settings.UserSourcePath" and check for the value
--> FUNNY: It' not the value that I have in the settings, but a value that I set at runtime when debugging before.
Everything else seems to work quite normal, e.g. the settings I made show in the projects properties as supposed to.
I have no idea where this alternative setting is stored i.e. from where it's retrieved. Searching the string with Ctrl-F doesn't give any results.
Could someone please give me any hints how to resolve this strange effect? Where can I search for the string that's actually used instead of my intended setting?
Thank you,
Mick
|
|
|
|
|
I'm making some assumptions here because your post isn't specific.
If the breakpoint is on that line, it hasn't executed the line yet. You have to step through that line to the next one to get it to execute.
Now, if your "custom control" is in another project and you're putting settings in that project, it's not going to work. Settings will always come from the application you're using the control in, not the controls own settings file.
|
|
|
|
|