How to get a post value in VB.Net - vb.net

I need help with getting a Value posted from a form in VB.Net.
At the moment there is a form on a php website that is posting 2 values through to me.
name=Max
email=test"test.com
If i was using php i would use :
$name = $_POST['name'];
$email = $_POST['email'];
Now the above fields are now captured within a variable.
How do i do the the same thing in VB.NET

I cannot tell if you are referring to Web text box's or PHP forms but I can help you with Web text box's..
Your question is unclear, but I will try my best.
Assuming you want to get a textbox's value into a variable. You would do like so:
Example Textbox:
<asp:TextBox ID="ExampleTxtBox" runat="server" AutoPostBack="True"></asp:TextBox>
If you want to assign the values on a certain command, for example, a button click. You would put this into the button click handles of the button.
Assuming you want to get the current text/value from the form's text box:
Dim VariableOfTextBox As String 'Creates your Variable
VariableOfTextBox = ExampleTxtBox.text 'Assigns the Value from your Text Box

Related

VB.NET add text to the front of text

I am trying to add text to current text that is in a textbox using a checkbox. Once the checkbox is checked, it will "add" the text to the textbox before the text already in the textbox.
example:
if the textbox said "Jake", it would say "Hello Jake" once the checkbox was checked.
EDIT: sorry for the quick question. I'm in a hurry. But the only method I could think of was concatenating and appending text. As far as I know append() adds only to the end, and concatening isn't the logical approach. I don't have a coded example because I dont even know how to approach this issue. thanks.
It's getting a thumbs down because its so simple, but not. I'm using multiple checkboxes. So one needs to be in the very front, one in the center, etc. Each checkbox injects text into the textbox a certain way. I can do this with nested if statements, but then we got a mess.
Try using this code :
if chbHello.Checked then
txtName.Text = chbHello.Text + " " + txtName.Text
Note : if the checkbox is the trigger put this code in the checkbox.
All it does is see if the checkbox was checked or not.
When its checked just concatenate the text of the textbox and the checkbox with the
checkbox first.

Based on form combobox selection to open the another form and move the value

I am new to access.
I have DFR form, From DFR form we are copy the record to different history card based on the asset code.
So what I did now I create one button and generate the code to open the form based on combobox selction ( the combobox contain the assed code no).
AFfter complete the DFR form press generate button it is opening the form what asset code contain in the combobox but i dont know how to copy the value from DFR form to the opened to asset code form. Because all the time I am not opening the same form so in the VBA I am not able to mention form name. Please help me
The code for the button:
Private Sub Command632_Click()
DoCmd.OpenForm Combo99.Value
End_Sub
according to the above command the form opened but iam not able move the value
For example I am using two form one is called as a DFR onother one is Mech_history card
in this case i know the designation form name. but above case i dont know the form name so please help me
What you want to do is pass an argument to the form that you are opening. This is possible as follows:
Private Sub Command632_Click()
DoCmd.OpenForm Combo99.Value, , , , , , "example"
End_Sub
Then in the form that is opening, you can use it for example as such:
Private Sub Form_Load()
Me.Label0.Caption = OpenArgs
End Sub
Where it will set the caption of Label0 to "example".
The OpenArgs argument is a single value, but you can pass multiple values by concatenating. This is already very well explained here: http://www.fmsinc.com/MicrosoftAccess/Forms/openargs/index.htm so it doesn't seem of added value of me to reword that for my answer here. Please take a look on that website.

MS Access: How to bound text box of form with query?

I created a form in MS Access 2010 and added a textbox here. Then I created a simple query (for example SELECT 10 AS studval;) and tried to set in Properties (of textbox) -> Data -> Control Source this query, but I got error #Name?.
How do I fix this error?
All names of query, textbox, query return values are correct. Or maybe are there any other ways to bound textbox and custom SQL query?
There is no easy way to do it, but it is possible using the form's On Activate event. First set up a query (Query1) with a single value called "studval" then open the form properties and add an Event Procedure for On Activate. It should look like this:
Private Sub Form_Activate()
Dim myString As String
myString = CurrentDb.QueryDefs("Query1").OpenRecordset.Fields("studval")
Me.Text0.SetFocus
[Text0].Text = myString
End Sub
You need to set the Control Source of the form to the query rather than the control source of the text box. A text box control source can only refer back to it's form's control source.
If you want just one text box bound to a query you have to create a subform linked to the parent form with that text box in it.

Populating label from user input on another form

I have populated a label in VB.Net using what has been input in a text box on another form however, when i then try and use the content of that label in a piece of code, it shows that there is nothing in the label?

How to set value of a editable combo box in an InternetExplorer window using VBScript?

can anyone please tell me how to set the value of a editable combobox in an IE window using vbscript?
I have set the IE window that i want to use, as an object.
If it was a text box, i have used
ie.document.all("textboxname").value = "textboxvalue"
For radiobutton, i have used
ie.document.all("radiobuttonname")(2).click --- where '2' is index of array (3rd value in array is selected)
For noneditable combobox, i have used
ie.document.all("comboboxname").selectedindex = 2 --- where '2' is index of array
All the above codes work fine, but I am not able to set value for the editable comboboxes in that IE window.
For editable combobox, i tried
ie.document.all("editablecomboboxname").selectedindex = 2
or
ie.document.all("editablecomboboxname").selectedindex.text = "text of any options in the combobox"
or
ie.document.all("editablecomboboxname").selectedindex(2).click
or
ie.document.all("editablecomboboxname").options.selected = 2
But everything leads to this error - "Object doesn't support this property or method: "
Can anyone help me with this? Thanks in advance
Please note I am using only VBscript and no other tools like Visual Studio or QTP.
As per Panayot Karabakalov asked, I have added an example of the code for one such editable combo box below :
<td class="small">
<span id="Curr Car Name" style = "display:none;" class = "small">
Curr Car Name
<font class="asteriskRed" style="font-size:11px" style="display:none;">*</font><br>
<input type="hidden" name='curr_car_name' id='curr_car_name' value='' style='width:180px;height=20px;' >
<script>
getTypeAhead(true,true,'curr_car_name',180,20,'null','AutoCompleteHighlight', 'AutoCompleteBackground','divclass','null',5,20,'curr_car_name_datasrc','','null',0,'setHHChangeIndicator();priorValidations();deleteRowFromAccordion(this);',310,100,'null','');
searchandFill('curr_car_name','',curr_car_name_datasrc);</script>
</span>
<input type="hidden" name="currentcarriernameHdd" id="currentcarriernameHdd" value="null"/>
</td
I saved the webpage(created in Java) as html file and viewed its source code. From there, I have copied and pasted the code for the combobox above. I am not sure if it will be helpful, as I dont have much knowledge of Java.
-- Deepak.
Well, I'll post what I have in mind.
Looking to the error description (Object doesn't support this property or method),
seems to me that your call-by-name...
ie.document.all("editablecomboboxname")
...return different object, i.e. not the element you expected. And as you have not
access to the plain HTML source code, that complicate debuging.
I suspect a naming conflict. What you can do is to see what returns your call-by-name.
MsgBox TypeName(ie.document.all("editablecomboboxname").Type)
But if there some naming conflict, I don't know how you can debug it without
the actual corresponding HTML code block.
# Panayot - Got the answer to my question!!
As you said, I tried with
MsgBox TypeName(ie.document.all("editablecomboboxname").Type)
It returned "String". So I went to a Java colleague of mine and asked him why the combobox is not getting updated even though inputtype is string. After a lot of discussion, he gave me two fields to update for the combobox - a label field to be updated with the string that I wanted in the combobox and another field to be updated with the value corresponding to the string I selected. This is what I used :
ie.document.all("curr_car_name").value = 8001
ie.document.all("_lblcurr_car_name").value = "NO PRIOR CARRIER"
The "curr_car_name" is the editable combobox name, and the "_lblcurr_car_name" is the label for the editable combobox. "NO PRIOR CARRIER" is the text that I wanted the combobox to have, and 8001 is its corresponding value. I got the value 8001 from the javascript that the webpage contained.
This works. :)
Thank you Panayot for all the help.