|
What if you put some breakpoints in your application, and then run from visual studio ? If they never get hit, then I'd be uninstalling and reinstalling the .NET framework.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Well, I tried uninstalling and reinstalling the framework, as well as VB.Net. I even tried a system restore. Nothing has changed.
Now what?
EDIT: Hmm, now breakpoints in both the Form1 Load event and the Application's startup event are working, as is (apparently) any code I put in there. But beyond those two subs, nothing happens, and the form never appears on the screen.
What the heck.
As I sit here, I contemplate the last words of Socrates: "I drank what?".
Pokémon Pearl Friend Code: 4554-2418-6836
modified on Tuesday, December 16, 2008 11:47 PM
|
|
|
|
|
I'll try and give a brief description of what I am trying to do... Basically I have a string that extracted from a text file called strCombined... I want to look at that string and if it contains a certain phrase then I want to act on it... If not then perform a default action...
Now I can do this pretty easily using a nested if...then...else statement... That's long winded and messy though...
If strCombined.IndexOf("Cambridge University") Then
strSearchName = "Cambridge University"
Else
If strCombined.IndexOf("FM Towns") Then
strSearchName = "FM Towns"
Else
If strCombined.IndexOf("Jupiter Cantab") Then
strSearchName = "Jupiter Cantab"
Else
strSearchName = ""
End If
End If
End If
I was hoping to use some kind of select...case statement instead...
Select Case strCombined
Case strCombined.IndexOf("Cambridge University")
strSearchName = "Cambridge Univeristy"
Case strCombined.IndexOf("FM Towns")
strSearchName = "FM Towns"
Case strCombined.IndexOf("Jupiter Cantab")
strSearchName = "Jupiter Cantab"
Case Else
strSearchName = ""
End Select
This obviously is not working... I'm hoping someone here can help me to either get this working with a select...case statement or suggest some other alternative...
Thanks in advance
|
|
|
|
|
because you're hoping to do an operation in each step, you're doing a search and not just checking different cases, there's not really an alternative that I can see.
However, this is really messy. Do you intend to accept FM Towns but not FM towns or fm towns ? Do you also intend that if someone types in more than one of these terms, then the order in which they are typed will dictate which one is accepted ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks for the prompt reply...
I don't really care if the case doesn't match... So I'll accept any variation of FM Towns... Though it comes from a Datfile and not from a user input... So it should be pretty consistent from one version of the Datfile to the next...
I've coded it using the if...then...else statement and it works just fine... Just hoping to find a more elegant solution I suppose...
|
|
|
|
|
If you want to be case insensitive, create a new string by calling ToLower on the one you have, and then compare to all lower case strings. Or there's a case insensitive compare method, but I always do the lower case string, it's surely more efficient ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
If I can't find a neater alternative to nested if statements then I'll look into that option... Anything that is more efficient and helps speed up the process is more than welcome
|
|
|
|
|
Try a test on strSearchName.Length and an if statement
If strCombined.Length = 0 and strCombined.IndexOf("Cambridge University") Then<br />
strSearchName = "Cambridge University"<br />
end if<br />
If strCombined.Length = 0 and strCombined.IndexOf("xxxx") Then<br />
strSearchName = "xxxx"<br />
end if
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How could a zero length string contain "Cambridge University"?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
This may not necessarily be more efficient, but it is a little more elegant, and it is easier to maintain in case you need to use more than the three values from your example:
Dim strSearchName As String = ""
Dim Values() As String = {"Cambridge University", "FM Towns", "Jupiter Cantab"}
For Each v As String In Values
If strCombined.IndexOf(v) Then strSearchName = v
Next
By setting strSearchName to be an empty string beforehand, it will be your default value if the loop doesn't assign it a value.
The array I used here enables you to use a settings file, or database table, or something like that. In case the amount of values you need to monitor grows really large, you can easily replace it with some other method of creating a collection of strings (DataTable, DataReader, etc.)
Using a loop here enables you to easily incorporate operations like String.ToLower, etc. or to perform other actions on strSearchName or strCombined, while you are at it.
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
I agree that this is the more maintainable solution.
Just some corrections to the code...
The IndexOf method returns an integer, not a boolean.
You want to exit from the loop as soon as you have found a string, otherwise the code doesn't do the same as the original code.
Dim strSearchName As String = ""
Dim Values() As String = {"Cambridge University", "FM Towns", "Jupiter Cantab"}
For Each v As String In Values
If strCombined.IndexOf(v) <> -1 Then
strSearchName = v
Exit For
End If
Next
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thank you both for this option... It's definitely better than using the nested if...then...else statements... Should work nicely... Thanks again...
|
|
|
|
|
Hi all...
I am creating a program for a small company to store all informations about its product.
There are several branches of company in many cities. So this program will be used in several cities.
The main job I have to do is, if a person in city1 or city2 sell a product and print its bill, then that program will send all informations of that product(name,price,qty,date of purchasing and selling etc.) to the main program running on the system of manager of the company(in another city).
Please suggest me how can I do this...
Thanks.
Gagan
|
|
|
|
|
Sounds like another rentacoder job gone bad to me.....
Obviously you need a central database to manage this, and then I would say that a webservice you can call to report a sale is what you're after.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
can u tell me how can I use webservice call to send information.
Gagan
|
|
|
|
|
Well, you do it by calling the webservice. I assume you have no idea what a webservice is, did you google it and read up on what I'm talking about ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.1
'
' NAME:
'
' AUTHOR: OEM USER , OEM USER
' DATE : 12/15/2008
'
' COMMENT:
'
'==========================================================================
'Option Explicit
Dim strComputer, passLen, accName, inputFile, newpass
'-----------------------------------
passLen = 128
accName = "itdadmin"
strComputer = "."
'inputFile = strComputer
inputFile = "C:\COMPUTERS.TXT"
'-----------------------------------
newpass = generatePassword(passLen)
Set objShell = CreateObject("WScript.Shell")
Set objWshScriptExec = objShell.Exec("c:\windows\system32\pspasswd.exe @" &chr(34) &inputFile &chr(34) &" " &accName &" " &newpass )
'Set objWshScriptExec = objShell.Exec("c:\windows\system32\pspasswd.exe @" &chr(34) &strComputer &chr(34) &" " &accName &" " &newpass )
'Set objStdOut = objWshScriptExec.StdOutstrOutput = objStdOut.ReadAll
WScript.Echo date & "," & time & VbCrLf&"NewPassword: "& newpass& vbCrLf& vbCrLf & strOutput
Set objShell = Nothing
wscript.quit
Function generatePassword(PASSWORD_LENGTH)
Dim NUMLOWER, NUMUPPER, LOWERBOUND, UPPERBOUND, LOWERBOUND1, UPPERBOUND1, SYMLOWER, SYMUPPER
Dim newPassword, count, pwd
Dim pCheckComplex, pCheckComplexUp, pCheckComplexLow, pCheckComplexNum, pCheckComplexSym, pCheckAnswer
NUMLOWER = 48 ' 48 = 0
NUMUPPER = 57 ' 57 = 9
LOWERBOUND = 65 ' 65 = A
UPPERBOUND = 90 ' 90 = Z
LOWERBOUND1 = 97 ' 97 = a
UPPERBOUND1 = 122 ' 122 = z
SYMLOWER = 33 ' 33 = !
SYMUPPER = 46 ' 46 = .
pCheckComplexUp = 0 ' used later to check number of character types in password
pCheckComplexLow = 0 ' used later to check number of character types in password
pCheckComplexNum = 0 ' used later to check number of character types in password
pCheckComplexSym = 0 ' used later to check number of character types in password
' initialize the random number generator
Randomize()
newPassword = ""
count = 0
DO UNTIL count = PASSWORD_LENGTH
' generate a num between 2 and 10
' if num < 5 create an uppercase
If Int( ( 10 - 2 + 1 ) * Rnd + 2 ) < 5 Then
pwd = Int( ( UPPERBOUND - LOWERBOUND + 1 ) * Rnd + LOWERBOUND )
' if num is between 4 and 7 create a lowecase
Elseif Int( ( 10 - 2 + 1 ) * Rnd + 2 ) > 3 And Int( ( 10 - 2 + 1 ) * Rnd + 2 ) < 8 Then
pwd = Int( ( UPPERBOUND1 - LOWERBOUND1 + 1 ) * Rnd + LOWERBOUND1 )
' if num is between 8 and 10 generate a symbol
Else
pwd = Int( ( SYMUPPER - SYMLOWER + 1 ) * Rnd + SYMLOWER )
End If
newPassword = newPassword + Chr( pwd )
count = count + 1
'Check to make sure that a proper mix of characters has been created. If not discard the password.
If count = (PASSWORD_LENGTH) Then
For pCheckComplex = 1 To PASSWORD_LENGTH
'Check for uppercase
If Asc(Mid(newPassword,pCheckComplex,1)) >64 And Asc(Mid(newPassword,pCheckComplex,1))< 90 Then
pCheckComplexUp = 1
'Check for lowercase
ElseIf Asc(Mid(newPassword,pCheckComplex,1)) >96 And Asc(Mid(newPassword,pCheckComplex,1))< 123 Then
pCheckComplexLow = 1
'Check for numbers
ElseIf Asc(Mid(newPassword,pCheckComplex,1)) >47 And Asc(Mid(newPassword,pCheckComplex,1))< 58 Then
pCheckComplexNum = 1
'Check for symbols
ElseIf Asc(Mid(newPassword,pCheckComplex,1)) >32 And Asc(Mid(newPassword,pCheckComplex,1))< 47 Then
pCheckComplexSym = 1
End If
Next
'Add up the number of character sets. We require 3 or 4 for a complex password.
pCheckAnswer = pCheckComplexUp+pCheckComplexLow+pCheckComplexNum+pCheckComplexSym
If pCheckAnswer < 3 Then
newPassword = ""
count = 0
End If
End If
Loop
'The password is good so return it
generatePassword = newPassword
End Function
|
|
|
|
|
bohicamaster wrote: How can I target the local system instead of using a txt file for a Ramdom Password Change to all computer system
Uhhh... what? I don't understand what you're trying to do. You're going to have to explain the process you're using, why you're using files, and why you want to "target the local system". What does "target the local system" mean?? What are you ultimately trying to do with this??
|
|
|
|
|
How can this ever be rated a "good answer"? it is nothing but more questions
|
|
|
|
|
Is there anything that I missed? I wanted to make sure there no doubt that I had no idea what he was trying to do. What do you think?
|
|
|
|
|
Dave Kreskowiak wrote: Is there anything that I missed?
You sure didn't miss another opportunity to ask more questions...
|
|
|
|
|
I have the following code that groups a generic List(Of T) that I want to order by IMRecord.BusinessUnit, but I can't get it to work. Can anyone help me with this?
Dim query = From IMRecord In ImRecordList _
Group By IMRecord.BusinessUnit, _
IMRecord.DocType, _
IMRecord.Description, _
IMRecord.VendorCode, _
IMRecord.DocDate, _
IMRecord.PONumber, _
IMRecord.DocNumber, _
IMRecord.Account _
Into Group, Purchases = Sum(CDec(IMRecord.Purchases)), _
Debit = Sum(CDec(IMRecord.Debit)), _
Credit = Sum(CDec(IMRecord.Credit)) _
Order By IMRecord.BusinessUnit
If I take off the Order By the grouping works ok.
|
|
|
|
|
Looks like the into is in the wrong place. SQL format (assuming that's being used?):
select
into
from
where
group by
order by
cheers!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Is it possible to create and instantiate a VB6 .dll in VB .Net without having a reference to the VB6 .dll? I tried to use the Assembly.LoadFrom method, which doesn't seem to work (and probably isn't intended for ActiveX .dlls).
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Can you just create an assembly with the name VB6.dll?
|
|
|
|
|