What is the problem with the StrComp code below - vba

The code below seems to have an issue that I can't see, can someone please advise me what I've done wrong?
If StrComp(Nz(TempVars!UserName), "Developer", vbBinaryCompare) = 0 And StrComp(Nz(TempVars!Password), "-Hget%$12l", vbBinaryCompare) = 0 Then

I worked out the issue, the corrected code is. Thanks everyone, Appreciated.
If StrComp(Nz(Me.txtUserName), "Developer", vbBinaryCompare) = 0 And StrComp(Nz(Me.txtPassword), "Try1", vbBinaryCompare) = 0 Then

Related

vba getelelementbyclassname()

I'm beginner
I am studying about web scraping but, I have some problem i can't solve by myself.
I need your soultion.
I'm finding it that how to input getelementbytagname(a) in getelementbyclassname() with for function
like this:
For i = 0 To 23
Cells(3 + i, 5) = doc.getElementsByClassName("name").getElementsByTagName("a")(i).innerText
Cells(3 + i, 5).WrapText = False
Next i
'=========================================================
'above code
'this was error
what is problem?
help me.
thanks a lot
I'm waiting your answer

VBConversion from string "a" to type 'Boolean' is not valid

If TextBox1.Text = Strings.Right(TextBox1.Text, 1) = "a" Then
Else
MsgBox("suffixes must A")
End If
Can someone help me?
Try this way :
if textbox1.text = Strings.Right(Textbox1.text,1) And Textbox1.Text = "a" Then
If I've quite understood what you meant, should be working. Good luck, hope I've been useful!

Crystal Report XI error in formula using Basic Syntax " 'THEN' Missing "

I am getting an error 'THEN' Missing
If I play around with the formatting I eventually will get it to highlight the ELSE IF all the way down to formula = line.
I have attached screenshots to show what I mean with the highlight.
I have come to realize that crystal report is finicky about formatting sometimes, can anyone provide insight or the correct approach to get this formula working?
Thanks in advance!
dim qtyavailable as number
IF ISNULL({HB_AVAILABLE_QTY_SKU\\.AVAIL})
THEN qtyavailable = 0
ELSE IF ({HB_AVAILABLE_QTY_SKU\\.AVAIL}) = 0
AND ({INVENTORY_PART\\.PRIME_COMMODITY})
LIKE FLY* OR SPC*
THEN "NA"
ELSE IF {SHOP_MATERIAL_ALLOC\.QTY_REQUIRED} = {SHOP_MATERIAL_ALLOC\.QTY_ASSIGNED}
THEN qtyavailable = {HB_AVAILABLE_QTY_SKU\\.AVAIL}+{SHOP_MATERIAL_ALLOC\.QTY_ASSIGNED}
ELSE qtyavailable = {HB_AVAILABLE_QTY_SKU\\.AVAIL}
END IF
END IF
END IF
formula = qtyavailable
You need to have the "THEN" be on the same line as the "IF" so a modified pseudocode of your if statement would be similar to:
IF ISNULL({foo}) THEN
qtyavailable = 0
ELSE
IF ({foo}="0" AND {foo} LIKE "1") THEN
' do nothing
ELSE
IF {foo} = {bar} THEN
qtyavailable = 2
ELSE
qtyavailable = 3
END IF
END IF
END IF

VB6 code explanation

I need to convert some of the legacy code which is currently in VB6 into C#. I am not able to understand this piece of code. Especially the InStr function, could someone please help me out with this and suggest me it's C# equivalent.
For i = 1 To Len(sString)
sChar = Mid$(sString, i, 1)
iPos = InStr(1, "0123456789", sChar, vbBinaryCompare)
If iPos > 0 Then
sRetStr = sRetStr & sChar
End If
Next i
The InStr finds the (one-based) index of a string in another string. The closest equivalent in the modern .Net string methods is .IndexOf. However, I would replace the code you have with this C# statement.
string sRetStr = (sString.Where((c) => char.IsDigit(c)).ToArray()).ToString();
I'd pare that code down to this:
sRetStr = Regex.Replace(sSTring, "[^0-9]", "");

Visual Basic 2008 - color

I have the following code, but I don't have any idea what happens in this code. So I don't know how to prepare an interface for this. Someone please tell me what the purpose of the array "Mylist" is. I haven't worked with "color" keyword before. Thanks in advance
Dim Mylist(4) As Color
Dim i As Integer
For i = 0 To 4
If i Mod 2 = 0 Then
Mylist(i) = Color.White
Else
Mylist(i) = Color.Red
End If
Next
The "purpose" of Mylist is whatever the person who wrote the code intended it to be. It is an array of five Colors. The code sets Mylist(0), Mylist(2) and Mylist(4) to White, and Mylist(1), Mylist(3) to Red.