Per cercare una lettera in una parola che viene inserita dall'utente esiste una funzione, del tipo "Mid" o qlcn simile di manipolazione stringhe?
Per cercare una lettera in una parola che viene inserita dall'utente esiste una funzione, del tipo "Mid" o qlcn simile di manipolazione stringhe?
Funzione InStr()
05.08.2005 - by alka
Auguri all'angelo custode dei moderatori.
Grazie
Ma io posso impostare come carattere di partenza da cui cercare un carettere che so per certo che è compreso nella stringa?
Devo analizzare una stringa che corrisponde ad un'equazione.
Ad esempio: y'=e^(2x)+3y
per trovare il 2x come posso fare, cioè per trovare ciò che sta dentro le parentesi, che è per forza un esponente??
par1 = InStr(ee, "(")
parr1 = Mid(ee, par1 + 1)
con questo riesco a isolare la stringa successiva alla parentesi aperta;
par2 = InStr(ee, ")")
parr = Mid(ee, par2)
con questa isolo ciò che è dopo la parentesi chiusa. Ora per trovare ciò che sta nel mezzo a queste 2 stringhe??
Allora, ho messo su un form 4 TextBox e un CommandButton, e ho scritto il seguente codice:
codice:Private Sub Form_Load() Text1.Text = "y'=e^(2x)+3y" Text2.Text = "" Text3.Text = "" Text4.Text = "" End Sub Private Sub Command1_Click() Text2.Text = "" Text3.Text = "" Text4.Text = "" Dim strValore As String Dim intInd As Integer Dim intIndUno As Integer Dim strSinistra As String Dim strCentro As String Dim strDestra As String ' legge il valore della text1, quello da scomporre strValore = Text1.Text ' SINISTRA intInd = InStr(1, strValore, "(", vbTextCompare) strSinistra = Mid(strValore, 1, intInd - 1) ' DESTRA intIndUno = InStr(1, strValore, ")", vbTextCompare) strDestra = Mid(strValore, intIndUno + 1, Len(strValore)) ' CENTRO strCentro = Mid(strValore, intInd + 1, _ Len(strValore) - intIndUno - 1) Text2.Text = strSinistra Text3.Text = strDestra Text4.Text = strCentro End Sub![]()
05.08.2005 - by alka
Auguri all'angelo custode dei moderatori.