What is the Java equivalent of Visual BAsic ASC() and MID() functions
Hello all! I just would like to ask if you have any idea on how to convert the VB ASC() and MID() functions into java. Where:
1. ASC( ) Function - Returns the ANSI value for the leftmost character in a character expression.
2. MID() Function - The Mid method extracts a substring of length nCount characters from a CHString string, starting at position nFirst (zero-based). The method returns a copy of the extracted substring.
I would really appreciate your help. Thanx!
ah yeah! sorry typo error. see, I am converting a VB method that encrypts password:
Function EncryptText(ByVal stDecryptedText As String)
Dim stText As String, lngCounter As Long
Dim iTemp As Integer, lngNumber As Long
lngCounter = 1
lngNumber = 8
Do Until lngCounter = Len(stDecryptedText) + 1
iTemp = Asc(Mid(stDecryptedText, lngCounter, 1))
If lngCounter Mod 2 = 0 Then
iTemp = iTemp - lngNumber
Else
iTemp = iTemp + lngNumber
End If
iTemp = iTemp Xor (10 - lngNumber)
stText = stText & Chr$(iTemp)
lngCounter = lngCounter + 1
Loop
EncryptText = stText
End Function
I converted this function into this:
public static String encryptPass(String password) {
String encpwd = "";
int iTemp = 0;
final int lngNumber = 8;
String stText = "";
for ( int i = 0; i < password.length() ; i++ ) {
iTemp = Character.getNumericValue(password.charAt(i));
if ( i % 2 == 0 ) {
iTemp = iTemp - lngNumber;
} else {
iTemp = iTemp + lngNumber;
iTemp = iTemp ^ (10 - lngNumber);
char c = Character.forDigit(iTemp,Character.MAX_RADIX);
encpwd = encpwd + String.valueOf(c);
return encpwd;
But I'm having trouble with the encryption because it returns a different set of characters. Did I convert it right? thanx.
Similar Messages
-
HT201364 What is the change betwen mac book late 2006 and mid 2007 ?
What is the change betwen mac book late 2006 and mid 2007 that couses the OS X Mavericks not to run on it?
Neither the 2006 or 2007 MacBooks will run Mavericks, nor will the white plastic cased 2008 models. The oldest MacBook that will run Mavericks is the Aluminum case Late 2008 one.
Looking at the specs, I think that is because prior to the aluminum 2008 model, all MacBooks used less powerful Intel Graphics Media Accelerator (GMA) graphics processors with (at most) 160 MB of available video memory. AFAIK, neither Intel nor Apple ever released 64 bit drivers for these GMA graphics processors, so when OS X dropped support for booting into 32 bit mode in Mountain Lion (OS X 10.8) that meant the newest OS these MacBooks could support was Leopard (OS X 10.7), the last version to support 32 bit mode.
It is also likely that the GMA's, with their limited memory & support for parallel processing, can't effectively support technologies like Grand Central Dispatch that system services in the newer OS versions increasingly rely on to speed up more than graphics rendering.
So, even if one could find a 64 bit driver for the GMA's, the system probably would be too slow at too many things to be practical. (Personally, I have a while 2008 MacBook, & I think the "best fit" OS for it is Snow Leopard. As far as I'm concerned, Lion is basically a beta version of Mountain Lion with too many rough edges & limited user choice to run on mine.) -
What replaced the LOAD command in Visual Basic 6?
VB6 died with XP. I'm trying to re-write a VB6 app in Visual Studio Community. The VB6 project used the LOAD and UNLOAD commands to create and delete copies of text boxes on the form. How do I accomplish that with the latest version of Visual Basic under
Visual Studio?
Thanks,
VBhobbist
VBHobbyistFrank,
[snip]
I'm sure it can be done, but how can I learn without coming back to this forum with every little question?
[snip]
Hey, I will gladly be here for any questions.
Public Class Form1
'the new .NET manual is online now:
' - go to https://google.com
' - type 'msdn [keyword]' (i.e: 'msdn list')
' - the first result is almost what is desired
' - if not enough information is given that is what the forumns are for!
'declaring array for textbox
' also note that -1 is the size, this is desirable so that textBoxes is initialized as an empty array so that when properties such as '.length' is used an exception wont be thrown saying the array is nothing
' note that some people prefer List(Of T) T means any type -> List is one of the most useful things in .NET and HIGHLY optimized. I did not use it here because it is an entirely new concept
' to learn more about list: http://msdn.microsoft.com/en-us/library/6sh2ey19(v=vs.110).aspx
Private textBoxes(-1) As TextBox
Private Sub setupTextBoxes()
'setup the amount of textboxes you want
ReDim textBoxes(14)
'initialize an integer and loop thru the length of the array
For delta As Integer = 0 To textBoxes.Length - 1
'set current array position to a new object (note that the [TextBox class].New function will be called)
textBoxes(delta) = New TextBox()
'setup gui properties, note that as you are coding, the type will show up
' also note that when coding:
' x = New [type]
' it is similar to
' x = 0
' ^New Integer/String/Double/etc.
textBoxes(delta).Size = New Size(100, 21)
textBoxes(delta).Location = New Point(1, delta * 21)
textBoxes(delta).Visible = True
'note that all form objects that have a container can hold other form objects
' we add to the form
Me.Controls.Add(textBoxes(delta))
Next delta
End Sub
Private Sub getTextBoxStuff()
'note that all variables can be initialized uppon declaration
Dim strAllTextBoxes As String = ""
'initialize an integer and loop thru the length of the array
For delta As Integer = 0 To textBoxes.Length - 1
'note that there are new operators (+=, -=, &=, etc.)
'also, controlchars is the new way to use certain chars, and messagebox.show is the new msgbox
strAllTextBoxes &= "TextBox " & delta.ToString & " = '" & textBoxes(delta).Text & "'" & ControlChars.CrLf
'note: there are way more ways to concatenate strings now, for production you can benchmark each one for different purposes
Next delta
MessageBox.Show(strAllTextBoxes, "Form1", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load '< Note that this is how subs are linked to gui elements now with the 'Handles' keyword
'define a new button
Dim btnGather As New Button
'setup gui properties
btnGather.Size = New Size(100, 21)
btnGather.Location = New Point(110, 0)
btnGather.Text = "Click Me"
'add control to form, note that anywhere else, the button can be gathered again thru Me.Controls()
Me.Controls.Add(btnGather)
'add a handler, note that when typeing this, you can see what parameter types the handler needs
AddHandler btnGather.Click, AddressOf btnGather_Click
setupTextBoxes()
End Sub
Private Sub btnGather_Click(ByVal sender As Object, ByVal e As EventArgs)
getTextBoxStuff()
End Sub
End Class
Create a new Windows Form project and paste this, press play.
Enjoy.
EDIT:
If you post blocks of code here, I will personally convert it to .NET, although I highly recommend a creating new project when converting from VB6. If you post your entire project and it's not too big I will convert the entire thing (any complex concepts
will have to have provided comments).
If your project is not secure or personal you can copy it to your online cloud OneDrive and I can download the whole thing from there - let me know. -
What is the Java equivalent to Windows SystemMetrics?
Hello,
I would like to retrieve component metrics on items such as titlebar height, horizontal scrollbar height, default font etc.
Unfortunately, I want to know the information without neccessarily having an instance of the control type visible (ie I want to know how high my forms titlebar will be before I create the form).
The reason I need this is to feed information back to a third party product that requires the type of details that you could query from the SystemMetrics available in Windows.
The tricky part is that the windows app needs to know these details before the Java app has created its first form.
Any help would be much appreciated,
thankyou, Sean.thankyou camickr,
that link was very useful - please have the dukes.
one thing that the link code doesn't give details about is how to find the metrics on the top level containers. Do you have any suggestions? -
What is the java equivalent to #define
Hi,
What would this declaration be in java:
#define STRAIGHT_FLUSH 1
Many thanks, RonThere is no direct equivalent. As mentioned, enums can be used to fill one of #define's roles. (enumerated values)
public static final constant member variables can fulfill another. (named constants)
And actually, if I understand correctly, #define is not part of the C language per se, but belongs in the realm of the preprocessor, and you can run Java code through a c preprocessor.
EDIT: Yeah, you can:
:; cat X.java
#define blah int
public class X {
Y y;
blah x;
jeff@shiro:/tmp 14:33:34
:; cpp -P !$
cpp -P X.java
public class X {
Y y;
int x;
}Message was edited by:
jverd -
What's the Java equivalent of a .dll file?
If any?
Actually, DLL for Windows. Where as in java,
It's doesn't dynamically link.
It's some what like Reflection classes. -
What is the Java equivalent to sapcpe
After upgrading to ECC6 EHP5 I find none of my dialog servers have the updated jar files or bootstrap.properties file in the j2ee\cluster\bootstrap folder.
How do jar files get copied from from server to anotherHi,
Please refer this link for more information on how sapcpe works.
http://help.sap.com/saphelp_nwpi711/helpdata/en/27/44f17a26a74a8abfd202c4f5dc9a0f/content.htm
Also refer this link
http://al-infotech.com/news/2006/12/30/use-sapcpe-for-kernel-update-on-netweaver-2004-as-java-by-yu-nong-zhang-sap/
I hope this clarifies.
Regards,
Naveen. -
I'm looking for the following info: CPU, RAM, Windows Server version, SQL Server version. Also, is the storage disk HDD or SSD?
Hi,
Since Azure SQL is an PaaS service, hardware and server OS version is information that we don't relate to.
For example, if you run
Select @@version as Version
You get Microsoft SQL Azure (RTM) - 11.0.9226.14. Alt least in the server I have running to day.
If you want to know performance levels at the different tiers, take a look at this MSDN article.
Azure SQL Database Service Tiers and Performance Levels
http://msdn.microsoft.com/en-us/library/azure/dn741336.aspx
I hope this answer your question
/Anders Eide -
How to use java applets inside visual basic
hi everyone,
i am new to programming specially java so please bear with me.
having said that i am looking for a way to embed java applets in visual basic. so
1) is it possibele?
2) if yes(which i believe) then how?
we are supposed to use VB but i hate it so looking for this way .
any suggestions and help is whole-heartedly welcome.
kindly help me.
you can post ur replies here or mail me directly at my e-mail id
[email protected]thanx
i have 2 more queries.
1) is this IE ACTIVE-X CONTROL present by default in VB or do i have to download some add-ons?
2) how do i write a concurrent server in java . i mean is there any thing equivalent to the UNIX system's FORK()?what if i have to implement this in an applet?
thanx again. -
OT: What's the Mac equivalent of Microsoft Paint?
What's the Mac equivalent of Microsoft Paint?
It used to be MacPaint, but isn't that long gone?
Is it iLife? If so, in the specs I don't see any mention of
basic paint functions although maybe it has them.
Obviously I don't have a current Mac or I'd know the answer
to this.
Thanks.http://en.wikipedia.org/wiki/MacPaint
http://en.wikipedia.org/wiki/QuickDraw
http://www.pixelpoppin.com/dorena/
http://sarwat.net/painting/ -
Can anyone help i want to call java class using visual basic
I want to call java class using visual basic and send some arguments to the main class
Hi,
I don't know VB, but you can surely launch a command line like :
javaw.exe mypackage.MyMainClass myArgument1
Regards -
What are the java components?
hi iam new to this it field. this is the question asked by interviewer. so please help me.
what are the java components you can use in a webproject? how you use those components in your project?http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
-
What is the Oracle equivalent of the Microsoft Access FIRST function?
Using: Oracle 10gR2 RAC on SUSE Linux 9 (10.2.0.3)
In the process of converting a Microsoft Access database to Oracle, an Access query is using the FIRST function.
What is the Oracle equivalent of the Microsoft Access FIRST function?
In the attempt to convert, the Oracle FIRST_VALUE function was used. However, the same results was not achieved.
Thanks,
(BLL)
Query:
h2. ACCESS:
SELECT
TRE.GCUSNO,
UCASE([DCUSNO]) AS DCUSNO_STD,
*FIRST(UCASE([DNAME])) AS DNAME_STD*,
*FIRST(UCASE([DADDR])) AS DADDR_STD*,
*FIRST(UCASE([DCITY])) AS DCITY_STD*,
TRE.DSTATE,
FIRST(TRE.DZIP) AS DZIP,
TRE.DREGN,
TRE.DDIST,
TRE.DSLSMN,
TRE.DCHAIN,
TRE.MARKET,
TRE.MKTPGM,
TRE.EUMKT
FROM
TRE
GROUP BY
TRE.GCUSNO,
UCASE([DCUSNO]),
TRE.DSTATE,
TRE.DREGN,
TRE.DDIST,
TRE.DSLSMN,
TRE.DCHAIN,
TRE.MARKET,
TRE.MKTPGM,
TRE.EUMKT;
h2. ORACLE:
SELECT DISTINCT
TRE.GCUSNO,
UPPER(TRIM(TRE.DCUSNO)) AS DCUSNO_STD,
UPPER(TRIM(TRE.DNAME)) AS DNAME_STD,
UPPER(TRIM(TRE.DADDR)) AS DADDR_STD,
FIRST_VALUE(UPPER(TRIM(TRE.DNAME)) IGNORE NULLS) OVER (ORDER BY TRE.GCUSNO) AS DNAME_STD,
FIRST_VALUE(UPPER(TRIM(TRE.DADDR)) IGNORE NULLS) OVER (ORDER BY TRE.GCUSNO) AS DADDR_STD,
FIRST_VALUE(UPPER(TRIM(TRE.DCITY)) IGNORE NULLS) OVER (ORDER BY TRE.GCUSNO) AS DCITY_STD,
TRE.DSTATE,
TRE.DZIP,
FIRST_VALUE(UPPER(TRIM(TRE.DZIP)) IGNORE NULLS) OVER (ORDER BY TRE.DZIP ASC) AS DZIP,
TRE.DREGN,
TRE.DDIST,
TRE.DSLSMN,
TRE.DCHAIN,
TRE.MARKET,
TRE.MKTPGM,
TRE.EUMKT
FROM CRM.TREUP100R TRE
GROUP BY
TRE.GCUSNO,
UPPER(TRIM(TRE.DCUSNO)),
TRE.DNAME,
TRE.DADDR,
TRE.DCITY,
TRE.DSTATE,
TRE.DZIP,
TRE.DREGN,
TRE.DDIST,
TRE.DSLSMN,
TRE.DCHAIN,
TRE.MARKET,
TRE.MKTPGM,
TRE.EUMKT;A slight correction to odie's post. I think you want min not max to replicate the Access first function, but see below to be sure. So:
min(upper(trim(tre.dname))) keep (dense_rank first order by tre.gcusno) as dname_std
user10860953 wrote:How does one ignore null values?The min and max functions will ignore nulls automatically, so if there is a null value in tre.dname, it will not be be returned, unless all of the values are null. For example:
SQL> WITH t AS (
2 SELECT 65 id, 'ABCD' col FROM dual UNION ALL
3 SELECT 37, 'DEFG' FROM dual UNION ALL
4 SELECT 65, 'DEFG' FROM dual UNION ALL
5 SELECT 65, null FROM dual UNION ALL
6 SELECT 70, null FROM dual UNION ALL
7 SELECT 70, null FROM dual UNION ALL
8 SELECT 37, 'ABC' from dual)
9 SELECT id,
10 MIN(col) keep (DENSE_RANK FIRST ORDER BY id) min_dname_std,
11 MAX(col) keep (DENSE_RANK FIRST ORDER BY id) max_dname_std
12 FROM t
13 GROUP BY id;
ID MIN_ MAX_
37 ABC DEFG
65 ABCD DEFG
70John -
What is the mac equivalent to adobe acrobat?
what is the mac equivalent to adobe acrobat?
Adobe Acrobat. http://www.adobe.com/products/acrobatpro/tech-specs.html
Stedman -
What is the mac equivalent to a right clic on a windows machine
What is the Mac equivalent to a right click? I installed Office for Mac 2011 on my macbook pro and I need to right click over a file from an ealier version of Office to make Office 2011 the default version of office. This is all in preparation to install Lion (Lion won't support Office 2004 and I can't afford to lose access to these files).
CTRL+click
CTRL=control (in between the fn and alt/option keys).
You can also go into System Preferences --> Trackpad and ensure "Secondary Click" is checked so that a two finger tap will act as a "right-click."
Maybe you are looking for
-
OS: Windows 7 Home Premium SP1 Hewlett Packard Model: 2000 2a20ca Notebook Oh my god please give me some insight here, it is so hard to find the right answers and I refuse to lose to this technical box that's driving me nuts! So here's the run down:
-
Renaming a file inside a function in PL/SQL
Hi, I have a file called TMP_g2_response_data. I have some data in it. I read the data inside my function. Once I read the data, I want to move it to some another file. Basically I want to rename the file TMP_g2_response_data to TMP_g2_response_data.
-
Error in Async - Sync "Localization failed: ResourceBundle"
Hello Experts, I have a scenario in which im receiving an idoc, transforming it into an XML and sending to a webservices through SOAP channel. The response from the webservices is transformed into a RFC BAPI and sent back to R/3 This is the error i a
-
Help! FCP 6.0.5 keeps crashing.
While working on my project a message popped up saying I was 'out of auto-save memory'. I checked and there was more than 100GB available on the auto-save drive. The allocated scratch disks also have more than 100GB available. Within seconds of the o
-
Having trouble opening up iTunes app on iPhone5. Why? How do I fix?
Having trouble opening iTunes app on iphone5. Why and how do I fix?