PDA

View Full Version : Hiển thị kí tự hóa học



kohf
16-04-2004, 22:22
Cho em hỏi có cách nào hiển thị được các kí tự hóa học như CH4 hay công thức toán x bình phương trong VB6 ko. Nếu có thể xử lí bằng text thì càng tốt.

ITbaby
17-04-2004, 05:04
Anh tạo mới 1 Projeact sau đó add 1 RichtextBox vào form . Sau đó Chép hết đoạn Code sau vào. F9 --> Fun lol lol
Private Sub Form_Load()
RichTextBox1.Font.Name = "Times New Roman"
RichTextBox1.Font.Size = 10
RichTextBox1.Text = _
"H2SO4" & vbCrLf & _
"H2O" & vbCrLf & _
"CO2"

RichTextBox1.SelStart = 1
RichTextBox1.SelLength = 1
RichTextBox1.SelCharOffset = -50
RichTextBox1.SelStart = 4
RichTextBox1.SelLength = 1
RichTextBox1.SelCharOffset = -50
RichTextBox1.SelStart = 8
RichTextBox1.SelLength = 1
RichTextBox1.SelCharOffset = -50
RichTextBox1.SelStart = 14
RichTextBox1.SelLength = 1
RichTextBox1.SelCharOffset = -50

RichTextBox1.SelStart = 0
RichTextBox1.SelLength = 0
End Sub


Private Sub Form_Paint()
CurrentX = 120
CurrentY = RichTextBox1.Top + _
RichTextBox1.Height + 120
Print "H";
CurrentY = CurrentY + 60
Print "2";
CurrentY = CurrentY - 60
Print "SO";
CurrentY = CurrentY + 60
Print "4";
CurrentY = CurrentY - 60

CurrentX = 120
CurrentY = CurrentY + ScaleY(1.5 * Font.Size, vbPoints, ScaleMode)
Print "H";
CurrentY = CurrentY + 60
Print "2";
CurrentY = CurrentY - 60
Print "O";

CurrentX = 120
CurrentY = CurrentY + ScaleY(1.5 * Font.Size, vbPoints, ScaleMode)
Print "CO";
CurrentY = CurrentY + 60
Print "2";
CurrentY = CurrentY - 60
End Sub