what are the components to formulate a unique identifier like GUID - vba

I have recently heard about GUID which is a global unique identifier. However, i would like to formulate my own unique identifier with components such as random numbers, timestamp, ip adress and userID. I would like to have my end result to be in the format of 19 digits (long variable). What are the other components that i can add? I am currently using Visual Basic.

set obj = CreateObject("Scriptlet.TypeLib")
msgbox obj.GUID
If you want your own then create it.

Related

Confused about Tensorflow Algorithm function

Colab notebook
Under the section on Feature Columns, there is this specific line of code
feature_columns = [ ]
for feature_name in CATEGORICAL_COLUMNS:
vocabulary = dftrain[feature_name].unique()
I'm struggling to understand what this is doing. I don't really know what to search up too as I'm still quite new to programming. Why is there a need for this line? I understand that it outputs all unique values of the specified feature_name, but don't get how it's linked to the next line.
When you don't understand a function just google the module name (TensorFlow) and the function name. I found the documentation for tf.feature_column.categorical_column_with_vocabulary_list described here. To quote the documentation:
Use this when your inputs are in string or integer format, and you have an in-memory vocabulary mapping each value to an integer ID. By default, out-of-vocabulary values are ignored.
What this section of code is doing is going through each column and mapping each unique string value to a unique integer (its location in the vocabulary list). Transforming your column using this type of mapping is common for categorical data. The reason that unique is needed is because tf.feature_column.categorical_column_with_vocabulary_list needs a unique list as an argument before it can work its magic.
In the future please put all necessary code in the question. It should not be required to visit another link to answer your question.

What's the proper way to let vb.net program to read a list?

For example, say I have a vb.net program and I want the program to be able to reference country codes. If I know the country name I wants to know the country code and via versa.
I can hardcode all the country in the program.
I can make the program read a text file
What would be the proper way?
I am thinking of something like string table in ios programming where instead of telling what a label should say you make a table and then the code reference that table. Something like resource file? Does vb.net have that?
It will be better if you will have the data in a file in your hard drive instead of "hardcoded" ,
it will be easier to change, add, replace, delete values , not mention if you will suddenly decide to move to another country ;)
I would make an enumeration list.
i.e.
Public Enum CountryCodes
Albania = 355
Algeria = 213
American Samoa= 684
End Enum
Find enum
Dim value As CountryCodes = CountryCodes.Algeria

Get Text Symbol Programmatically With ID

Is there any way of programmatically getting the value of a Text Symbol at runtime?
The scenario is that I have a simple report that calls a function module. I receive an exported parameter in variable LV_MSG of type CHAR1. This indicates a certain status message created in the program, for instance F (Fail), X (Match) or E (Error). I currently use a CASE statement to switch on LV_MSG and fill another variable with a short description of the message. These descriptions are maintained as text symbols that I retrieve at compile time with text-MS# where # is the same as the possible returns of LV_MSG, for instance text-MSX has the value "Exact Match Found".
Now it seems to me that the entire CASE statement is unnecessary as I could just assign to my description variable the value of the text symbol with ID 'MS' + LV_MSG (pseudocode, would use CONCATENATE). Now my issue is how I can find a text symbol based on the String representation of its ID at runtime. Is this even possible?
If it is, my code would look cleaner and I wouldn't have to update my actual code when new messages are added in the function module, as I would simply have to add a new text symbol. But would this approach be any faster or would it in fact degrade the report's performance?
Personally, I would probably define a domain and use the fixed values of the domain to represent the values. This way, you would even get around the string concatenation. You can use the function module DD_DOMVALUE_TEXT_GET to easily access the language-dependent text of a domain value.
To access the text elements of a program, use a function module like READ_TEXT_ELEMENTS.
Be aware that generic programming like this will definitely slow down your program. Whether it would make your code look cleaner is in the eye of the beholder - if the values change rarely, I don't see why a simple CASE statement should be inferior to some generic text access.
Hope I understand you correctly but here goes. This is possible with a little trickery, all the text symbols in a report are defined as variables in the program (with the name text-abc where abc is the text ID). So you can use the following:
data: lt_all_text type standard table of textpool with default key,
lsr_text type ref to textpool.
"Load texts - you will only want to do this once
read textpool sy-repid into lt_all_text language sy-langu.
sort lt_all_Text by entry.
"Find a text, the field KEY is the text ID without TEXT-
read table lt_all_text with key entry = i_wanted_text
reference into lsr_text binary search.
If you want the address you can add:
field-symbols: <l_text> type any.
data l_name type string.
data lr_address type ref to data.
concatenate 'TEXT-' lsr_text->key into l_name.
assign (l_name) to <l_text>.
if sy-subrc = 0.
get reference of <l_text> into lr_address.
endif.
As vwegert pointed out this is probably not the best solution, for error handling rather use message classes or exception objects. This is useful in other cases though so now you know how.

GUID lookup in table fails when culture is set to "Danish"

Dim ii = _DsAttribute.Tables(0).Rows.Find(Convert.ToString(DtgFields.Rows(e.RowIndex).Cells("AttributeID").Value, CultureInfo.CreateSpecificCulture("en-US"))) '.ToString.ToString(CultureInfo.InvariantCulture))
Dim jj = _DsAttribute.Tables(0).Rows.Find(Convert.ToString(DtgFields.Rows(e.RowIndex).Cells("AttributeID").Value, CultureInfo.CreateSpecificCulture("en-US"))).Item("Checked")
I tried many variations of the above, trying to keep the database's data from being "corrupted" by my machine's Danish culture (set in region/language settings in Windows). I tried invariant culture, fr-FR and en-US.
When my machine is Danish, ii equals null and jj returns an exception ("Object reference not set to an instance of an object") but, interestingly, _DsAttribute has the same data as when my machine is English (US-English). Also, when I search for the value of DtgFields.Rows(e.RowIndex).Cells("AttributeID").Value, I can find it in the data from _DsAttribute. The data for the ID is, at least to the naked eye, the same.
How do I make use of CultureInfo to avoid this sort of problem?
This is technically possible, Danish uses a different sort order than US-English. You'll find Mr Åårdvårk at the beginning of the phone book in Denmark, not at the end as in the USA.
That makes string comparison a dangerous proposition if the Find() method uses binary search or a tree to locate the data. Which is certainly the case for DataSet, its primary key index is a red-black tree. What goes wrong is that the algorithm follows the wrong path down the tree when the index was written with Danish as the collation but is read with English as the collation. Or the other way around. The result is that it can't find an entry in the tree, even though it exists.
Contra-indications is that a dbase column of type Guid should never be a string, although it is not uncommon that it is. And that Guid values should not contain characters that can steer the search wrong. Maybe the column isn't clean and contains other, non-guid values. You fix it by changing the column type or by using the same collation order (i.e. language) consistently. Try CultureInfo.CurrentCulture for a possible quick fix.
Dim ii = _DsAttribute.Tables(0).Rows.Find(New Guid(DtgFields.Rows(e.RowIndex).Cells("AttributeID").Value.ToString))
Dim jj = _DsAttribute.Tables(0).Rows.Find(New Guid(DtgFields.Rows(e.RowIndex).Cells("AttributeID").Value.ToString)).Item("Checked")
The above was the solution, for me. Hans' answer has lots of technical information that was very helpful (thus my upvote) and lead me to my answer.

sql injection in integer field

I have an app, and the username field will convert any given value to the integer value using integer.parseint. The app uses JSP and Oracle database.
The URL has been tested with SQLMap and it is not dynamic. So, the only way I can try is via the login form, but I could not bypass it.
When I put ' or 1=1, -- ,the server return error, error for input string.
I want to inject the field, so, how can it be done?
I don't know whether I can use the alternate encoding because it will convert that to integer anyway.
It can't be done.
If the value is parsed as an integer, it can no longer contain any harmful code.