Skip to content

Instantly share code, notes, and snippets.

@Aminadav
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aminadav/edba25d40507ae66a36f to your computer and use it in GitHub Desktop.
Save Aminadav/edba25d40507ae66a36f to your computer and use it in GitHub Desktop.
Textarea in VBA and visual basic
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} frm
ClientHeight = 4665
ClientLeft = 45
ClientTop = 390
ClientWidth = 6315
OleObjectBlob = "ff.frx":0000
RightToLeft = -1 'True
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public ok
Private Sub CommandButton1_Click()
ok = True
Me.Hide
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
t = TextBox1
If KeyCode = 13 Then
t = Replace(TextBox1, vbCrLf, "`")
t = Left(t, TextBox1.SelStart) & "`" & Mid(t, TextBox1.SelStart + 1)
Rem msgbox t & vbCrLf & "-" & vbCrLf & TextBox1
t = Replace(t, "`", vbCrLf)
ss = TextBox1.SelStart
TextBox1 = t
TextBox1.SelStart = ss + 1
TextBox1.SetFocus
KeyCode = 0
Else
Rem UserForm_KeyPress KeyCode
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Rem KeyAscii = 0
End Sub
Private Sub UserForm_Activate()
TextBox1.SetFocus
End Sub
Public Function inputbox(Optional prompt As String, Optional title As String, Optional default As String)
Me.Caption = title
Me.Label1 = prompt
Me.TextBox1 = default
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = 1000
Me.Show 1
If ok Then inputbox = Me.TextBox1
End Function
Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 27 Then
TextBox1.Text = ""
ok = False
Me.Hide
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment