Executing a string value
-
-
Hi, I used this code on button1_click of a button in Windows form and it displayed me with the messagebox Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strMsg As String Dim strMsgNew As String = "Pritpal Singh Bumrah" strMsg = MsgBox(strMsgNew) strMsg.ToString() End Sub I hope this should solve your problems dickysingh Nothing New
-
Hi, I used this code on button1_click of a button in Windows form and it displayed me with the messagebox Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strMsg As String Dim strMsgNew As String = "Pritpal Singh Bumrah" strMsg = MsgBox(strMsgNew) strMsg.ToString() End Sub I hope this should solve your problems dickysingh Nothing New
Thank you for your answer My problem is more complicated. Please consider there is a textbox and a button in my form When i click to the button the code that i wrote it into textbox , must be executed. But i will not use only msgbox. I will use all of the Vb.NET functions like (int - left - mid ....) I used to develop it in vb6 using scripting control object it was able to use ... script1.execute text1.text like this.. It executes the code that i have written into textbox. Thanks Best Regards Emre YAZICI
-
Thank you for your answer My problem is more complicated. Please consider there is a textbox and a button in my form When i click to the button the code that i wrote it into textbox , must be executed. But i will not use only msgbox. I will use all of the Vb.NET functions like (int - left - mid ....) I used to develop it in vb6 using scripting control object it was able to use ... script1.execute text1.text like this.. It executes the code that i have written into textbox. Thanks Best Regards Emre YAZICI
There is nothing that says you can't do the exact same thing in VB.Net. All you have to do is go to the references folder in your project, right click it and select Add Reference. Go to the COM tab, scroll down to Microsoft Script Control 1.0, double-click it then click OK. Back in your project, open the code for your Form and put the following line BEFORE the Public Class statement for your Form:
Imports MSScriptControl
Now declare a script control object in an appropriate place in your code, set the control to the language you want to use, and tell it to execute the code you want. Here is a short example:
Imports MSScriptControl
Public Class Form1
Inherits System.Windows.Forms.Form
' Windows Form Designer generated code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim script As New MSScriptControlClass
script.Language = "VBScript"
script.ExecuteStatement("msgbox ""This is a test...""")
End Sub
End ClassRageInTheMachine9532